More RFU documentation

This commit is contained in:
PikalaxALT
2020-01-30 10:48:42 -05:00
parent 96a7ad2fc5
commit 78196be41e
7 changed files with 309 additions and 282 deletions
+45 -36
View File
@@ -54,7 +54,7 @@ static void sub_80FACF0(u8 taskId);
static void GetLinkmanErrorParams(u32 msg);
static void sub_80FB564(s32 a0);
static void sub_80FBB74(void);
static u8 sub_80FBC70(const u8 *a0, u16 a1);
static u8 GetPartnerIndexByNameAndTrainerID(const u8 *trainerName, u16 trainerId);
static void sub_80FBCF8(u32 bmDisconnectSlot);
static void sub_80FBE20(u32 a0, u32 a1);
static void sub_80FC028(u8 taskId);
@@ -138,8 +138,10 @@ static const struct {
{ gBlockSendBuffer, 40 }
};
static const u16 gUnknown_843EC8C[] = {
0x0002, 0x7f7d, 0xFFFF
static const u16 sAcceptedSerialNos[] = {
0x0002, // Pokemon FR/LG/EM
0x7f7d,
0xFFFF
};
static const char sUnref_843EC92[][15] = {
@@ -240,7 +242,7 @@ static void sub_80F8738(u8 taskId)
case 1:
break;
case 2:
rfu_LMAN_establishConnection(Rfu.unk_0c, 0, 240, (u16*)gUnknown_843EC8C);
rfu_LMAN_establishConnection(Rfu.unk_0c, 0, 240, (u16*)sAcceptedSerialNos);
Rfu.unk_04 = 3;
gTasks[taskId].data[1] = 6;
break;
@@ -326,7 +328,7 @@ static void sub_80F893C(u8 taskId)
case 1:
break;
case 6:
rfu_LMAN_establishConnection(Rfu.unk_0c, 0, 240, (u16*)gUnknown_843EC8C);
rfu_LMAN_establishConnection(Rfu.unk_0c, 0, 240, (u16*)sAcceptedSerialNos);
Rfu.unk_04 = 7;
gTasks[taskId].data[1] = 7;
break;
@@ -395,7 +397,7 @@ static void sub_80F8AEC(void)
static void sub_80F8B34(u8 taskId)
{
if (GetHostRFUtgtGname()->unk_0a_0 == 0x54 && sub_80FB9F4() == 4)
if (GetHostRFUtgtGname()->activity == 0x54 && sub_80FB9F4() == 4)
{
rfu_REQ_disconnect(lman.acceptSlot_flag);
rfu_waitREQComplete();
@@ -411,7 +413,7 @@ static void sub_80F8B34(u8 taskId)
case 1:
break;
case 17:
rfu_LMAN_establishConnection(2, 0, 240, (u16*)gUnknown_843EC8C);
rfu_LMAN_establishConnection(2, 0, 240, (u16*)sAcceptedSerialNos);
rfu_LMAN_setMSCCallback(sub_80F8D20);
Rfu.unk_04 = 18;
break;
@@ -456,7 +458,7 @@ static void sub_80F8B34(u8 taskId)
void sub_80F8CFC(void)
{
rfu_LMAN_establishConnection(1, 0, 240, (u16*)gUnknown_843EC8C);
rfu_LMAN_establishConnection(1, 0, 240, (u16*)sAcceptedSerialNos);
}
void sub_80F8D14(void)
@@ -1015,7 +1017,7 @@ static void sub_80F9868(u8 unused)
{
Rfu.unk_80[i].unk_12 = 2;
Rfu_SetBlockReceivedFlag(i);
if (GetHostRFUtgtGname()->unk_0a_0 == 0x45 && gReceivedRemoteLinkPlayers != 0 && Rfu.unk_0c == 0)
if (GetHostRFUtgtGname()->activity == 0x45 && gReceivedRemoteLinkPlayers != 0 && Rfu.unk_0c == 0)
sub_80FAA58(gBlockRecvBuffer);
}
}
@@ -1439,12 +1441,12 @@ void sub_80FA42C(void)
}
}
bool32 sub_80FA44C(u32 a0)
bool32 RfuSerialNumberIsValid(u32 serialNo)
{
s32 i;
for (i = 0; gUnknown_843EC8C[i] != a0; i++)
for (i = 0; sAcceptedSerialNos[i] != serialNo; i++)
{
if (gUnknown_843EC8C[i] == 0xFFFF)
if (sAcceptedSerialNos[i] == 0xFFFF)
return FALSE;
}
return TRUE;
@@ -1541,9 +1543,9 @@ bool32 sub_80FA5D4(void)
return FALSE;
}
bool32 sub_80FA634(u16 a0, const u8 *a1)
bool32 sub_80FA634(u16 trainerId, const u8 *trainerName)
{
u8 r1 = sub_80FBC70(a1, a0);
u8 r1 = GetPartnerIndexByNameAndTrainerID(trainerName, trainerId);
if (r1 == 0xFF)
return TRUE;
if (Rfu.unk_cd1[r1] == 9)
@@ -1553,7 +1555,7 @@ bool32 sub_80FA634(u16 a0, const u8 *a1)
void sub_80FA670(u8 a0, u16 a1, const u8 *a2)
{
u8 r4 = sub_80FBC70(a2, a1);
u8 r4 = GetPartnerIndexByNameAndTrainerID(a2, a1);
Rfu.unk_cd1[r4] = a0;
rfu_clearSlot(TYPE_NI_SEND, r4);
rfu_NI_setSendData(1 << r4, 8, Rfu.unk_cd1 + r4, 1);
@@ -1566,9 +1568,9 @@ void sub_80FA6BC(void)
rfu_NI_setSendData(1 << Rfu.unk_c3e, 8, &Rfu.unk_c85, 1);
}
u32 sub_80FA6FC(u16 a0, const u8 *a1)
u32 sub_80FA6FC(u16 trainerId, const u8 *trainerName)
{
u8 r0 = sub_80FBC70(a1, a0);
u8 r0 = GetPartnerIndexByNameAndTrainerID(trainerName, trainerId);
if (r0 == 0xFF)
return 2;
if (gRfuSlotStatusNI[r0]->send.state == 0)
@@ -1955,7 +1957,7 @@ void sub_80FB030(u32 linkPlayerCount)
u32 r7;
s32 r8;
if (GetHostRFUtgtGname()->unk_0a_0 == 0x45)
if (GetHostRFUtgtGname()->activity == 0x45)
{
r5 = 0;
r7 = 0;
@@ -2028,7 +2030,7 @@ static void sub_80FB184(u8 msg, u8 param_count)
if ((lman.param[0] >> i) & 1)
{
struct GFtgtGname *structPtr = (void *)&gRfuLinkStatus->partner[i].gname;
if (structPtr->unk_0a_0 == GetHostRFUtgtGname()->unk_0a_0)
if (structPtr->activity == GetHostRFUtgtGname()->activity)
{
Rfu.unk_cd1[i] = 0;
Rfu.unk_cd5[i] = 0;
@@ -2196,7 +2198,7 @@ static u8 sub_80FB5A0(s32 a0)
if ((a0 >> i) & 1)
{
struct GFtgtGname *structPtr = (void *)&gRfuLinkStatus->partner[i].gname;
if (structPtr->unk_0a_0 == 0x45)
if (structPtr->activity == 0x45)
ret |= (1 << i);
}
}
@@ -2217,7 +2219,7 @@ static void sub_80FB5EC(u8 msg, u8 param_count)
sub_80FB9E4(4, 0);
break;
case LMAN_MSG_NEW_CHILD_CONNECT_ACCEPTED:
if (GetHostRFUtgtGname()->unk_0a_0 == 0x45 && Rfu.unk_cd9 == 0)
if (GetHostRFUtgtGname()->activity == 0x45 && Rfu.unk_cd9 == 0)
{
u8 idx = sub_80FB5A0(lman.param[0]);
if (idx != 0)
@@ -2240,7 +2242,7 @@ static void sub_80FB5EC(u8 msg, u8 param_count)
Rfu.unk_ce4 = 2;
}
}
else if (GetHostRFUtgtGname()->unk_0a_0 == 0x54)
else if (GetHostRFUtgtGname()->activity == 0x54)
{
rfu_REQ_disconnect(lman.acceptSlot_flag);
rfu_waitREQComplete();
@@ -2252,7 +2254,7 @@ static void sub_80FB5EC(u8 msg, u8 param_count)
case LMAN_MSG_SEARCH_CHILD_PERIOD_EXPIRED:
break;
case LMAN_MSG_END_WAIT_CHILD_NAME:
if (GetHostRFUtgtGname()->unk_0a_0 != 0x45 && lman.acceptCount > 1)
if (GetHostRFUtgtGname()->activity != 0x45 && lman.acceptCount > 1)
{
r1 = 1 << sub_80F886C(lman.param[0]);
rfu_REQ_disconnect(lman.acceptSlot_flag ^ r1);
@@ -2491,17 +2493,24 @@ static u16 ReadU16(const void *ptr)
return (ptr_[1] << 8) | (ptr_[0]);
}
static u8 sub_80FBC70(const u8 *a0, u16 a1)
/*
* ================================================================
* Looks up the player by uname and pid. Returns the index in
* gRfuLinkStatus->partner of the first match with a valid slot ID.
* Returns 0xFF if not found.
* ================================================================
*/
static u8 GetPartnerIndexByNameAndTrainerID(const u8 *trainerName, u16 trainerId)
{
u8 i;
u8 ret = 0xFF;
for (i = 0; i < RFU_CHILD_MAX; i++)
{
u16 trainerId = ReadU16(((struct GFtgtGname *)gRfuLinkStatus->partner[i].gname)->unk_00.playerTrainerId);
if (sub_80FA44C(gRfuLinkStatus->partner[i].serialNo)
&& !StringCompare(a0, gRfuLinkStatus->partner[i].uname)
&& a1 == trainerId)
u16 partnerTrainerId = ReadU16(((struct GFtgtGname *)gRfuLinkStatus->partner[i].gname)->unk_00.playerTrainerId);
if (RfuSerialNumberIsValid(gRfuLinkStatus->partner[i].serialNo)
&& !StringCompare(trainerName, gRfuLinkStatus->partner[i].uname)
&& trainerId == partnerTrainerId)
{
ret = i;
if (gRfuLinkStatus->partner[i].slot != 0xFF)
@@ -2522,9 +2531,9 @@ static void sub_80FBCF8(u32 bmDisconnectSlot)
Rfu.unk_cda = sub_80F886C(Rfu.bm_PartnerFlags);
}
void sub_80FBD4C(const u8 *ptr, u16 a1)
void sub_80FBD4C(const u8 *trainerName, u16 trainerId)
{
u8 var = sub_80FBC70(ptr, a1);
u8 var = GetPartnerIndexByNameAndTrainerID(trainerName, trainerId);
if (var != 0xFF)
sub_80FBCF8(1 << var);
}
@@ -2581,7 +2590,7 @@ static void sub_80FBE80(u8 taskId)
if (sub_80F8EA4())
{
u8 id = sub_80FBC70((u8*)data, ReadU16(&data[8]));
u8 id = GetPartnerIndexByNameAndTrainerID((u8*)data, ReadU16(&data[8]));
if (id != 0xFF)
{
if (gRfuLinkStatus->partner[id].slot != 0xFF)
@@ -2590,7 +2599,7 @@ static void sub_80FBE80(u8 taskId)
if (sub_80F8ECC())
DestroyTask(taskId);
}
else if (GetHostRFUtgtGname()->unk_0a_0 == 0x15 || GetHostRFUtgtGname()->unk_0a_0 == 0x16)
else if (GetHostRFUtgtGname()->activity == 0x15 || GetHostRFUtgtGname()->activity == 0x16)
{
data[15]++;
}
@@ -2632,12 +2641,12 @@ void sub_80FBF54(const u8 *src, u16 trainerId)
static bool32 sub_80FBF98(s16 a1, struct GFtgtGname *structPtr)
{
if (GetHostRFUtgtGname()->unk_0a_0 == 0x45)
if (GetHostRFUtgtGname()->activity == 0x45)
{
if (structPtr->unk_0a_0 != 0x45)
if (structPtr->activity != 0x45)
return TRUE;
}
else if (structPtr->unk_0a_0 != 0x40)
else if (structPtr->activity != 0x40)
{
return TRUE;
}
@@ -2676,7 +2685,7 @@ static void sub_80FC028(u8 taskId)
if (Rfu.unk_ccd != 0 && lman.parent_child == 0)
{
u16 trainerId = ReadU16(((struct GFtgtGname *)&Rfu.unk_104.gname)->unk_00.playerTrainerId);
u8 id = sub_80FBC70(Rfu.unk_104.uname, trainerId);
u8 id = GetPartnerIndexByNameAndTrainerID(Rfu.unk_104.uname, trainerId);
if (id != 0xFF)
{
if (!sub_80FBF98(gTasks[taskId].data[1], (struct GFtgtGname *)&gRfuLinkStatus->partner[id].gname))
+16 -3
View File
@@ -617,7 +617,7 @@ void InitHostRFUtgtGname(struct GFtgtGname *data, u8 activity, bool32 r2, s32 r3
r3 >>= 8;
}
data->playerGender = gSaveBlock2Ptr->playerGender;
data->unk_0a_0 = activity;
data->activity = activity;
data->unk_0a_7 = r2;
data->unk_00.unk_00_0 = GAME_LANGUAGE;
data->unk_00.unk_01_2 = GAME_VERSION;
@@ -629,6 +629,13 @@ void InitHostRFUtgtGname(struct GFtgtGname *data, u8 activity, bool32 r2, s32 r3
data->unk_00.gameClear = FlagGet(FLAG_SYS_GAME_CLEAR);
}
/*
* ==========================================================
* Returns 1 if parent, 0 if child or neutral.
* If partner serial number is valid, copies gname and uname.
* Otherwise, blanks these.
* ==========================================================
*/
bool8 sub_80FCC3C(struct GFtgtGname *gname, u8 *uname, u8 idx)
{
bool8 retVal;
@@ -636,7 +643,7 @@ bool8 sub_80FCC3C(struct GFtgtGname *gname, u8 *uname, u8 idx)
if (lman.parent_child == MODE_PARENT)
{
retVal = TRUE;
if (sub_80FA44C(gRfuLinkStatus->partner[idx].serialNo) && ((gRfuLinkStatus->getNameFlag >> idx) & 1))
if (RfuSerialNumberIsValid(gRfuLinkStatus->partner[idx].serialNo) && ((gRfuLinkStatus->getNameFlag >> idx) & 1))
{
memcpy(gname, &gRfuLinkStatus->partner[idx].gname, RFU_GAME_NAME_LENGTH);
memcpy(uname, gRfuLinkStatus->partner[idx].uname, RFU_USER_NAME_LENGTH);
@@ -650,7 +657,7 @@ bool8 sub_80FCC3C(struct GFtgtGname *gname, u8 *uname, u8 idx)
else
{
retVal = FALSE;
if (sub_80FA44C(gRfuLinkStatus->partner[idx].serialNo))
if (RfuSerialNumberIsValid(gRfuLinkStatus->partner[idx].serialNo))
{
memcpy(gname, &gRfuLinkStatus->partner[idx].gname, RFU_GAME_NAME_LENGTH);
memcpy(uname, gRfuLinkStatus->partner[idx].uname, RFU_USER_NAME_LENGTH);
@@ -664,6 +671,12 @@ bool8 sub_80FCC3C(struct GFtgtGname *gname, u8 *uname, u8 idx)
return retVal;
}
/*
* ==========================================================
* Specific check for serial number 0x7F7D,
* which comes from ???
* ==========================================================
*/
bool8 sub_80FCCF4(struct GFtgtGname *gname, u8 *uname, u8 idx)
{
bool8 retVal = FALSE;
+5 -5
View File
@@ -473,7 +473,7 @@ static u8 sub_811BBA0(u32 r1, u32 unused, struct GFtgtGname * r2)
{
return gUnknown_845711B[r1];
}
else if (r2->unk_0a_0 == 0x45)
else if (r2->activity == 0x45)
{
return 1;
}
@@ -542,7 +542,7 @@ static void sub_811BCA0(u32 r7, struct GFtgtGname * r8)
static void sub_811BDA8(u32 r5, struct GFtgtGname * r4)
{
u32 i;
switch (r4->unk_0a_0)
switch (r4->activity)
{
case 0x40:
case 0x54:
@@ -584,11 +584,11 @@ static void UpdateUnionRoomPlayerSprites(struct UnkStruct_URoom *r0)
sUnionObjRefreshTimer = 0;
for (i = 0, r4 = r0->field_0->arr; i < 8; i++)
{
if (r4[i].field_1A_0 == 1)
if (r4[i].tradeStatus == 1)
{
sub_811BDA8(i, &r4[i].unk.gname);
}
else if (r4[i].field_1A_0 == 2)
else if (r4[i].tradeStatus == 2)
{
sub_811BE6C(i, &r4[i].unk.gname);
}
@@ -639,7 +639,7 @@ bool32 sub_811BF00(struct UnkStruct_Main0 *arg0, s16 *arg1, s16 *arg2, u8 *arg3)
{
continue;
}
if (r4[i].field_1A_0 != 1)
if (r4[i].tradeStatus != 1)
{
continue;
}
+230 -230
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -364,12 +364,12 @@ void sub_814F65C(u8 windowId, u8 fontId, const u8 * str, u8 x, u8 y, u8 palIdx)
u32 sub_814F714(struct UnkStruct_x20 * unk20, u32 * arg1)
{
u32 r8 = unk20->unk.gname.unk_0a_0;
u32 r8 = unk20->unk.gname.activity;
s32 i, j, k;
for (i = 0; i < NELEMS(gUnknown_846FAC0); i++)
{
if (r8 == gUnknown_846FAC0[i][0] && unk20->field_1A_0 == 1)
if (r8 == gUnknown_846FAC0[i][0] && unk20->tradeStatus == 1)
{
if (gUnknown_846FAC0[i][2] == 0)
{