diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/link_rfu_2.c | 390 | ||||
-rw-r--r-- | src/link_rfu_3.c | 10 | ||||
-rw-r--r-- | src/party_menu.c | 2 | ||||
-rw-r--r-- | src/trade.c | 2 | ||||
-rw-r--r-- | src/union_room.c | 180 | ||||
-rw-r--r-- | src/union_room_battle.c | 45 | ||||
-rw-r--r-- | src/union_room_message.c | 10 |
7 files changed, 321 insertions, 318 deletions
diff --git a/src/link_rfu_2.c b/src/link_rfu_2.c index f2567f3a3..12603a78a 100644 --- a/src/link_rfu_2.c +++ b/src/link_rfu_2.c @@ -26,8 +26,8 @@ static EWRAM_DATA struct InitializeParametersTag sRfuReqConfig = {}; static EWRAM_DATA struct UnkLinkRfuStruct_02022B44 gUnknown_203AC08 = {}; static u32 gf_rfu_REQ_api[RFU_API_BUFF_SIZE_RAM / 4]; -static u8 gUnknown_3001FF8[14]; -static u16 gUnknown_3002008[7]; +static u8 sResendBlock8[14]; +static u16 sResendBlock16[7]; struct GFtgtGname gHostRFUtgtGnameBuffer; GF_RFU_MANAGER Rfu; @@ -35,15 +35,15 @@ u8 gHostRFUtgtUnameBuffer[PLAYER_NAME_LENGTH + 1]; static void sub_80F8AA4(void); static void sub_80F8AEC(void); -static void sub_80F8D20(u16 a0); +static void MscCallback_Child(u16 a0); static void sub_80F8DA8(u16 a0); static void sub_80F906C(void); -static void sub_80F9868(u8 unused); -static void ResetSendDataManager(struct UnkRfuStruct_2_Sub_6c *data); +static void RfuHandleReceiveCommand(u8 unused); +static void ResetSendDataManager(struct RfuBlockSend *data); static void RfuPrepareSendBuffer(u16 command); -static void rfufunc_80F9F44(void); -static void sub_80F9FA8(void); -static void rfufunc_80FA020(void); +static void RfuFunc_HandleBlockSend(void); +static void RfuFunc_SendNextBlock(void); +static void RfuFunc_SendLastBlock(void); static void CallRfuFunc(void); static void sub_80FA738(void); static int sub_80FA788(void); @@ -56,7 +56,7 @@ static void GetLinkmanErrorParams(u32 msg); static void sub_80FB564(s32 a0); static void sub_80FBB74(void); static u8 GetPartnerIndexByNameAndTrainerID(const u8 *trainerName, u16 trainerId); -static void sub_80FBCF8(u32 bmDisconnectSlot); +static void RfuReqDisconnectSlot(u32 bmDisconnectSlot); static void sub_80FBE20(u32 a0, u32 a1); static void sub_80FC028(u8 taskId); static void sub_80FC208(void); @@ -83,7 +83,7 @@ static const u8 sAvailSlots[] = { [4] = AVAIL_SLOT4 }; -static const u32 gUnknown_843EBD4[] = { +static const u32 sAllBlocksReceived[] = { 0x000000, 0x000001, 0x000003, @@ -196,9 +196,9 @@ void sub_80F85F8(void) } for (i = 0; i < 5; i++) { - ResetSendDataManager(Rfu.unk_80 + i); + ResetSendDataManager(Rfu.cmd_8800_recvbuf + i); } - ResetSendDataManager(&Rfu.unk_6c); + ResetSendDataManager(&Rfu.cmd_8800_sendbuf); RFU_queue_20_70_reset(&Rfu.unk_124); RFU_queue_40_14_reset(&Rfu.unk_9e8); CpuFill16(0, gSendCmd, sizeof gSendCmd); @@ -233,25 +233,25 @@ void sub_80F86F4(void) static void sub_80F8738(u8 taskId) { sub_80FA738(); - switch (Rfu.unk_04) + switch (Rfu.state) { case 0: rfu_LMAN_initializeRFU(&sRfuReqConfig); - Rfu.unk_04 = 1; + Rfu.state = 1; gTasks[taskId].data[1] = 1; break; case 1: break; case 2: rfu_LMAN_establishConnection(Rfu.unk_0c, 0, 240, (u16*)sAcceptedSerialNos); - Rfu.unk_04 = 3; + Rfu.state = 3; gTasks[taskId].data[1] = 6; break; case 3: break; case 4: rfu_LMAN_stopManager(FALSE); - Rfu.unk_04 = 5; + Rfu.state = 5; break; case 5: break; @@ -260,7 +260,7 @@ static void sub_80F8738(u8 taskId) rfu_LMAN_setMSCCallback(sub_80F8DA8); sub_80F8AA4(); sub_80F8AEC(); - Rfu.unk_04 = 20; + Rfu.state = 20; gTasks[taskId].data[1] = 8; CreateTask(sub_80FA834, 5); DestroyTask(taskId); @@ -319,18 +319,18 @@ static void sub_80F887C(s32 r2, s32 r5) static void sub_80F893C(u8 taskId) { - switch (Rfu.unk_04) + switch (Rfu.state) { case 0: rfu_LMAN_initializeRFU((INIT_PARAM*)&sRfuReqConfigTemplate); - Rfu.unk_04 = 1; + Rfu.state = 1; gTasks[taskId].data[1] = 1; break; case 1: break; case 6: rfu_LMAN_establishConnection(Rfu.unk_0c, 0, 240, (u16*)sAcceptedSerialNos); - Rfu.unk_04 = 7; + Rfu.state = 7; gTasks[taskId].data[1] = 7; break; case 7: @@ -342,7 +342,7 @@ static void sub_80F893C(u8 taskId) switch (sub_80FA788()) { case 5: - Rfu.unk_04 = 12; + Rfu.state = 12; break; case 6: case 9: @@ -398,25 +398,25 @@ static void sub_80F8AEC(void) static void sub_80F8B34(u8 taskId) { - if (GetHostRFUtgtGname()->activity == 0x54 && RfuGetErrorStatus() == 4) + if (GetHostRFUtgtGname()->activity == (0x14 | 0x40) && RfuGetErrorStatus() == 4) { rfu_REQ_disconnect(lman.acceptSlot_flag); rfu_waitREQComplete(); RfuSetErrorStatus(0, 0); } - switch (Rfu.unk_04) + switch (Rfu.state) { case 0: rfu_LMAN_initializeRFU(&sRfuReqConfig); - Rfu.unk_04 = 1; + Rfu.state = 1; gTasks[taskId].data[1] = 1; break; case 1: break; case 17: rfu_LMAN_establishConnection(2, 0, 240, (u16*)sAcceptedSerialNos); - rfu_LMAN_setMSCCallback(sub_80F8D20); - Rfu.unk_04 = 18; + rfu_LMAN_setMSCCallback(MscCallback_Child); + Rfu.state = 18; break; case 18: break; @@ -437,7 +437,7 @@ static void sub_80F8B34(u8 taskId) break; case 14: rfu_LMAN_stopManager(0); - Rfu.unk_04 = 15; + Rfu.state = 15; break; case 15: break; @@ -447,7 +447,7 @@ static void sub_80F8B34(u8 taskId) sub_80FAFE0(1); sub_80F8AA4(); sub_80F8AEC(); - Rfu.unk_04 = 20; + Rfu.state = 20; gTasks[taskId].data[1] = 8; Rfu.unk_0c = 1; CreateTask(sub_80FA834, 5); @@ -467,7 +467,7 @@ void sub_80F8D14(void) rfu_LMAN_stopManager(FALSE); } -static void sub_80F8D20(u16 unused) +static void MscCallback_Child(u16 unused) { s32 i; @@ -544,7 +544,7 @@ static void sub_80F8E74(void) static bool8 sub_80F8EA4(void) { - if (Rfu.unk_04 == 7 && Rfu.unk_ccd) + if (Rfu.state == 7 && Rfu.parentId) { return TRUE; } @@ -553,9 +553,9 @@ static bool8 sub_80F8EA4(void) static bool32 sub_80F8ECC(void) { - if (Rfu.unk_04 == 7 && !rfu_LMAN_CHILD_connectParent(gRfuLinkStatus->partner[Rfu.unk_c3d].id, 240)) + if (Rfu.state == 7 && !rfu_LMAN_CHILD_connectParent(gRfuLinkStatus->partner[Rfu.unk_c3d].id, 240)) { - Rfu.unk_04 = 9; + Rfu.state = 9; return TRUE; } return FALSE; @@ -579,15 +579,15 @@ bool8 sub_80F8F40(void) void sub_80F8F5C(void) { - Rfu.unk_04 = 4; + Rfu.state = 4; Rfu.unk_ce7 = lman.acceptSlot_flag; } bool32 sub_80F8F7C(bool32 a0) { - if (Rfu.unk_04 == 17 || a0) + if (Rfu.state == 17 || a0) { - Rfu.unk_04 = 18; + Rfu.state = 18; return TRUE; } return FALSE; @@ -595,7 +595,7 @@ bool32 sub_80F8F7C(bool32 a0) void sub_80F8FA0(void) { - Rfu.unk_04 = 14; + Rfu.state = 14; } static void sub_80F8FAC(u8 a0) @@ -687,7 +687,7 @@ bool32 IsRfuRecvQueueEmpty(void) static bool32 sub_80F911C(void) { - if (Rfu.unk_04 < 20) + if (Rfu.state < 20) { rfu_REQ_recvData(); rfu_waitREQComplete(); @@ -702,7 +702,7 @@ static bool32 sub_80F911C(void) { if (Rfu.bm_DisconnectSlot) { - sub_80FBCF8(Rfu.bm_DisconnectSlot); + RfuReqDisconnectSlot(Rfu.bm_DisconnectSlot); Rfu.bm_DisconnectSlot = 0; if (Rfu.unk_ce4 == 1) { @@ -739,7 +739,7 @@ static bool32 sub_80F9204(void) u16 j; u8 retval; - if (Rfu.unk_04 >= 20 && Rfu.unk_0e == 1) + if (Rfu.state >= 20 && Rfu.unk_0e == 1) { rfu_waitREQComplete(); while (Rfu.unk_cdb == 0) @@ -786,7 +786,7 @@ static bool32 sub_80F9204(void) flags >>= 1; } sub_80F9038(); - sub_80F9868(0); + RfuHandleReceiveCommand(0); CallRfuFunc(); if (Rfu.unk_ce5 && !Rfu.unk_cd9) { @@ -840,7 +840,7 @@ static void sub_80F94BC(u16 *a0, u8 *a1) } } -static bool32 sub_80F9514(void) +static bool32 RfuProcessEnqueuedRecvBlock(void) { u8 i; u8 j; @@ -856,7 +856,7 @@ static bool32 sub_80F9514(void) gRecvCmds[i][j] = (sp00[i * 14 + (j << 1) + 1] << 8) | sp00[i * 14 + (j << 1) + 0]; } } - sub_80F9868(0); + RfuHandleReceiveCommand(0); if (lman.childClockSlave_flag == 0 && Rfu.unk_ce4) { rfu_REQ_disconnect(gRfuLinkStatus->connSlotFlag | gRfuLinkStatus->linkLossSlotFlag); @@ -887,29 +887,29 @@ static bool32 sub_80F9514(void) return IsRfuRecvQueueEmpty(); } -static void sub_80F965C(u8 unused, u32 flags) +static void HandleSendFailure(u8 unused, u32 flags) { s32 i, j; - const u8 *r10 = Rfu.unk_6c.payload; - for (i = 0; i < Rfu.unk_6c.count; i++) + const u8 *r10 = Rfu.cmd_8800_sendbuf.payload; + for (i = 0; i < Rfu.cmd_8800_sendbuf.count; i++) { if (!(flags & 1)) { - gUnknown_3002008[0] = (~0x76ff) | i; + sResendBlock16[0] = RFU_COMMAND_0x8900 | i; for (j = 0; j < 7; j++) { - gUnknown_3002008[j + 1] = (r10[12 * i + (j << 1) + 1] << 8) | r10[12 * i + (j << 1) + 0]; + sResendBlock16[j + 1] = (r10[12 * i + (j << 1) + 1] << 8) | r10[12 * i + (j << 1) + 0]; } for (j = 0; j < 7; j++) { - gUnknown_3001FF8[2 * j + 1] = gUnknown_3002008[j] >> 8; - gUnknown_3001FF8[2 * j + 0] = gUnknown_3002008[j]; + sResendBlock8[2 * j + 1] = sResendBlock16[j] >> 8; + sResendBlock8[2 * j + 0] = sResendBlock16[j]; j++;j--; // Needed to match; } - RFU_queue_40_14_recv(&Rfu.unk_9e8, gUnknown_3001FF8); - Rfu.unk_6c.unk_0c |= (1 << i); + RFU_queue_40_14_recv(&Rfu.unk_9e8, sResendBlock8); + Rfu.cmd_8800_sendbuf.failedFlags |= (1 << i); } flags >>= 1; } @@ -926,7 +926,7 @@ void Rfu_SetBlockReceivedFlag(u8 a0) void Rfu_ResetBlockReceivedFlag(u8 a0) { Rfu.unk_5c[a0] = 0; - Rfu.unk_80[a0].unk_12 = 0; + Rfu.cmd_8800_recvbuf[a0].receiving = 0; } static u8 sub_80F9770(const u8 *a0) @@ -951,7 +951,7 @@ static void RfuFunc_SendKeysToRfu(void) { gUnknown_3001188++; gHeldKeyCodeToSend |= (gUnknown_3001188 << 8); - RfuPrepareSendBuffer(0xbe00); + RfuPrepareSendBuffer(RFU_COMMAND_0xbe00); } } @@ -976,7 +976,7 @@ void Rfu_set_zero(void) Rfu.RfuFunc = NULL; } -static void sub_80F9868(u8 unused) +static void RfuHandleReceiveCommand(u8 unused) { u16 i; u16 j; @@ -985,55 +985,55 @@ static void sub_80F9868(u8 unused) { switch (gRecvCmds[i][0] & 0xff00) { - case 0x7800: + case RFU_COMMAND_0x7800: if (Rfu.unk_0c == 0 && gReceivedRemoteLinkPlayers != 0) return; // fallthrough - case 0x7700: + case RFU_COMMAND_0x7700: if (gRfuLinkStatus->parentChild == MODE_CHILD) { Rfu.playerCount = gRecvCmds[i][1]; Rfu.unk_cce = sub_80F9770((u8 *)(gRecvCmds[i] + 2)); } break; - case 0x8800: - if (Rfu.unk_80[i].unk_12 == 0) + case RFU_COMMAND_0x8800: + if (Rfu.cmd_8800_recvbuf[i].receiving == 0) { - Rfu.unk_80[i].unk_00 = 0; - Rfu.unk_80[i].count = gRecvCmds[i][1]; - Rfu.unk_80[i].owner = gRecvCmds[i][2]; - Rfu.unk_80[i].unk_08 = 0; - Rfu.unk_80[i].unk_12 = 1; + Rfu.cmd_8800_recvbuf[i].next = 0; + Rfu.cmd_8800_recvbuf[i].count = gRecvCmds[i][1]; + Rfu.cmd_8800_recvbuf[i].owner = gRecvCmds[i][2]; + Rfu.cmd_8800_recvbuf[i].receivedFlags = 0; + Rfu.cmd_8800_recvbuf[i].receiving = 1; Rfu.unk_5c[i] = 0; } break; - case 0x8900: - if (Rfu.unk_80[i].unk_12 == 1) + case RFU_COMMAND_0x8900: + if (Rfu.cmd_8800_recvbuf[i].receiving == 1) { - Rfu.unk_80[i].unk_00 = gRecvCmds[i][0] & 0xff; - Rfu.unk_80[i].unk_08 |= (1 << Rfu.unk_80[i].unk_00); + Rfu.cmd_8800_recvbuf[i].next = gRecvCmds[i][0] & 0xff; + Rfu.cmd_8800_recvbuf[i].receivedFlags |= (1 << Rfu.cmd_8800_recvbuf[i].next); for (j = 0; j < 6; j++) - 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].count]) + gBlockRecvBuffer[i][Rfu.cmd_8800_recvbuf[i].next * 6 + j] = gRecvCmds[i][j + 1]; + if (Rfu.cmd_8800_recvbuf[i].receivedFlags == sAllBlocksReceived[Rfu.cmd_8800_recvbuf[i].count]) { - Rfu.unk_80[i].unk_12 = 2; + Rfu.cmd_8800_recvbuf[i].receiving = 2; Rfu_SetBlockReceivedFlag(i); - if (GetHostRFUtgtGname()->activity == 0x45 && gReceivedRemoteLinkPlayers != 0 && Rfu.unk_0c == 0) + if (GetHostRFUtgtGname()->activity == (UROOM_ACTIVITY_CHAT | 0x40) && gReceivedRemoteLinkPlayers != 0 && Rfu.unk_0c == 0) sub_80FAA58(gBlockRecvBuffer); } } break; - case 0xa100: + case RFU_COMMAND_0xa100: Rfu_InitBlockSend(gUnknown_843EC64[gRecvCmds[i][1]].buffer, (u16)gUnknown_843EC64[gRecvCmds[i][1]].size); break; - case 0x5f00: + case RFU_COMMAND_0x5f00: Rfu.unk_e4[i] = 1; break; - case 0x6600: + case RFU_COMMAND_0x6600: if (Rfu.unk_100 == gRecvCmds[i][1]) Rfu.unk_e9[i] = 1; break; - case 0xed00: + case RFU_COMMAND_0xed00: if (Rfu.unk_0c == 0) { if (gReceivedRemoteLinkPlayers != 0) @@ -1050,13 +1050,13 @@ static void sub_80F9868(u8 unused) } else { - RfuPrepareSendBuffer(0xee00); + RfuPrepareSendBuffer(RFU_COMMAND_0xee00); gSendCmd[1] = gRecvCmds[i][1]; gSendCmd[2] = gRecvCmds[i][2]; gSendCmd[3] = gRecvCmds[i][3]; } break; - case 0xee00: + case RFU_COMMAND_0xee00: if (Rfu.unk_0c == 1) { Rfu.bm_DisconnectSlot |= gRecvCmds[i][1]; @@ -1064,7 +1064,7 @@ static void sub_80F9868(u8 unused) sub_80FA9D0(gRecvCmds[i][1]); } break; - case 0xbe00: + case RFU_COMMAND_0xbe00: gLinkPartnersHeldKeys[i] = gRecvCmds[i][1]; break; } @@ -1087,7 +1087,7 @@ static bool8 sub_80F9C50(void) for (i = 0; i < 5; i++) { - if (Rfu.unk_80[i].unk_12) + if (Rfu.cmd_8800_recvbuf[i].receiving) return FALSE; } return TRUE; @@ -1099,21 +1099,21 @@ static bool8 sub_80F9C78(void) for (i = 0; i < Rfu.playerCount; i++) { - if (Rfu.unk_80[i].unk_12 != 2 || Rfu.unk_5c[i] != 1) + if (Rfu.cmd_8800_recvbuf[i].receiving != 2 || Rfu.unk_5c[i] != 1) return FALSE; } return TRUE; } -static void ResetSendDataManager(struct UnkRfuStruct_2_Sub_6c *data) +static void ResetSendDataManager(struct RfuBlockSend *data) { - data->unk_00 = 0; + data->next = 0; data->count = 0; data->payload = NULL; - data->unk_08 = 0; - data->unk_10 = 0; + data->receivedFlags = 0; + data->sending = 0; data->owner = 0; - data->unk_12 = 0; + data->receiving = 0; } u8 Rfu_GetBlockReceivedStatus(void) @@ -1123,7 +1123,7 @@ u8 Rfu_GetBlockReceivedStatus(void) for (i = 0; i < 5; i++) { - if (Rfu.unk_80[i].unk_12 == 2 && Rfu.unk_5c[i] == 1) + if (Rfu.cmd_8800_recvbuf[i].receiving == 2 && Rfu.unk_5c[i] == 1) { flags |= (1 << i); } @@ -1140,16 +1140,16 @@ static void RfuPrepareSendBuffer(u16 command) gSendCmd[0] = command; switch (command) { - case 0x8800: - gSendCmd[1] = Rfu.unk_6c.count; - gSendCmd[2] = Rfu.unk_6c.owner + 0x80; + case RFU_COMMAND_0x8800: + gSendCmd[1] = Rfu.cmd_8800_sendbuf.count; + gSendCmd[2] = Rfu.cmd_8800_sendbuf.owner + 0x80; break; - case 0xa100: + case RFU_COMMAND_0xa100: if (sub_80F9C50()) gSendCmd[1] = Rfu.unk_5a; break; - case 0x7700: - case 0x7800: + case RFU_COMMAND_0x7700: + case RFU_COMMAND_0x7800: tmp = Rfu.bm_PartnerFlags ^ Rfu.bm_DisconnectSlot; Rfu.playerCount = gUnknown_843EC41[tmp] + 1; gSendCmd[1] = Rfu.playerCount; @@ -1157,20 +1157,20 @@ static void RfuPrepareSendBuffer(u16 command) for (i = 0; i < RFU_CHILD_MAX; i++) buff[i] = Rfu.unk_cde[i]; break; - case 0x6600: - case 0x5f00: + case RFU_COMMAND_0x6600: + case RFU_COMMAND_0x5f00: gSendCmd[1] = Rfu.unk_100; break; - case 0x2f00: + case RFU_COMMAND_0x2f00: for (i = 0; i < 6; i++) gSendCmd[1 + i] = Rfu.unk_f2[i]; break; - case 0xbe00: + case RFU_COMMAND_0xbe00: gSendCmd[1] = gHeldKeyCodeToSend; break; - case 0xee00: + case RFU_COMMAND_0xee00: break; - case 0xed00: + case RFU_COMMAND_0xed00: break; } } @@ -1180,7 +1180,7 @@ void sub_80F9E2C(void * data) if (gSendCmd[0] == 0 && !RfuIsErrorStatus1or2()) { memcpy(Rfu.unk_f2, data, sizeof(Rfu.unk_f2)); - RfuPrepareSendBuffer(0x2f00); + RfuPrepareSendBuffer(RFU_COMMAND_0x2f00); } } @@ -1192,77 +1192,77 @@ bool32 Rfu_InitBlockSend(const u8 *src, size_t size) return FALSE; if (gSendCmd[0] != 0) return FALSE; - if (Rfu.unk_6c.unk_10 != 0) + if (Rfu.cmd_8800_sendbuf.sending != 0) { gUnknown_203AC08.unk_83++; return FALSE; } r4 = (size % 12) != 0; - Rfu.unk_6c.owner = GetMultiplayerId(); - Rfu.unk_6c.unk_10 = 1; - Rfu.unk_6c.count = (size / 12) + r4; - Rfu.unk_6c.unk_00 = 0; - if (size > 0x100) - Rfu.unk_6c.payload = src; + Rfu.cmd_8800_sendbuf.owner = GetMultiplayerId(); + Rfu.cmd_8800_sendbuf.sending = 1; + Rfu.cmd_8800_sendbuf.count = (size / 12) + r4; + Rfu.cmd_8800_sendbuf.next = 0; + if (size > 0x100) // should never be reached + Rfu.cmd_8800_sendbuf.payload = src; else { if (src != gBlockSendBuffer) memcpy(gBlockSendBuffer, src, size); - Rfu.unk_6c.payload = gBlockSendBuffer; + Rfu.cmd_8800_sendbuf.payload = gBlockSendBuffer; } - RfuPrepareSendBuffer(0x8800); - Rfu.RfuFunc = rfufunc_80F9F44; + RfuPrepareSendBuffer(RFU_COMMAND_0x8800); + Rfu.RfuFunc = RfuFunc_HandleBlockSend; Rfu.unk_5b = 0; return TRUE; } -static void rfufunc_80F9F44(void) +static void RfuFunc_HandleBlockSend(void) { if (gSendCmd[0] == 0) { - RfuPrepareSendBuffer(0x8800); + RfuPrepareSendBuffer(RFU_COMMAND_0x8800); if (Rfu.unk_0c == 1) { if (++Rfu.unk_5b > 2) - Rfu.RfuFunc = sub_80F9FA8; + Rfu.RfuFunc = RfuFunc_SendNextBlock; } else { - if ((gRecvCmds[GetMultiplayerId()][0] & 0xff00) == 0x8800) - Rfu.RfuFunc = sub_80F9FA8; + if ((gRecvCmds[GetMultiplayerId()][0] & 0xff00) == RFU_COMMAND_0x8800) + Rfu.RfuFunc = RfuFunc_SendNextBlock; } } } -static void sub_80F9FA8(void) +static void RfuFunc_SendNextBlock(void) { s32 i; - const u8 *src = Rfu.unk_6c.payload; - gSendCmd[0] = 0x8900 | Rfu.unk_6c.unk_00; + const u8 *src = Rfu.cmd_8800_sendbuf.payload; + gSendCmd[0] = RFU_COMMAND_0x8900 | Rfu.cmd_8800_sendbuf.next; 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]; - Rfu.unk_6c.unk_00++; - if (Rfu.unk_6c.count <= Rfu.unk_6c.unk_00) + gSendCmd[i + 1] = (src[(i << 1) + Rfu.cmd_8800_sendbuf.next * 12 + 1] << 8) | src[(i << 1) + Rfu.cmd_8800_sendbuf.next * 12 + 0]; + Rfu.cmd_8800_sendbuf.next++; + if (Rfu.cmd_8800_sendbuf.count <= Rfu.cmd_8800_sendbuf.next) { - Rfu.unk_6c.unk_10 = 0; - Rfu.RfuFunc = rfufunc_80FA020; + Rfu.cmd_8800_sendbuf.sending = 0; + Rfu.RfuFunc = RfuFunc_SendLastBlock; } } -static void rfufunc_80FA020(void) +static void RfuFunc_SendLastBlock(void) { - const u8 *src = Rfu.unk_6c.payload; + const u8 *src = Rfu.cmd_8800_sendbuf.payload; u8 mpId = GetMultiplayerId(); s32 i; if (Rfu.unk_0c == 0) { - gSendCmd[0] = (~0x76ff) | (Rfu.unk_6c.count - 1); + gSendCmd[0] = RFU_COMMAND_0x8900 | (Rfu.cmd_8800_sendbuf.count - 1); for (i = 0; i < 7; i++) - 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.count - 1) + gSendCmd[i + 1] = (src[(i << 1) + (Rfu.cmd_8800_sendbuf.count - 1) * 12 + 1] << 8) | src[(i << 1) + (Rfu.cmd_8800_sendbuf.count - 1) * 12 + 0]; + if ((u8)gRecvCmds[mpId][0] == Rfu.cmd_8800_sendbuf.count - 1) { - if (Rfu.unk_80[mpId].unk_08 != gUnknown_843EBD4[Rfu.unk_80[mpId].count]) + if (Rfu.cmd_8800_recvbuf[mpId].receivedFlags != sAllBlocksReceived[Rfu.cmd_8800_recvbuf[mpId].count]) { - sub_80F965C(mpId, Rfu.unk_80[mpId].unk_08); + HandleSendFailure(mpId, Rfu.cmd_8800_recvbuf[mpId].receivedFlags); gUnknown_203AC08.unk_64++; } else @@ -1276,7 +1276,7 @@ static void rfufunc_80FA020(void) bool8 sub_80FA0F8(u8 a0) { Rfu.unk_5a = a0; - RfuPrepareSendBuffer(0xa100); + RfuPrepareSendBuffer(RFU_COMMAND_0xa100); return TRUE; } @@ -1342,7 +1342,7 @@ static void sub_80FA224(void) { if (gSendCmd[0] == 0 && !Rfu.unk_ce8) { - RfuPrepareSendBuffer(0x5f00); + RfuPrepareSendBuffer(RFU_COMMAND_0x5f00); Rfu.RfuFunc = sub_80FA1C4; } } @@ -1368,11 +1368,11 @@ static void sub_80FA2B0(void) u8 playerCount; u8 i; - if (GetMultiplayerId() != 0) + if (GetMultiplayerId() != 0) // child { - if (Rfu.unk_124.count == 0 && Rfu.unk_fe > 0x3c) + if (Rfu.unk_124.count == 0 && Rfu.unk_fe > 60) { - RfuPrepareSendBuffer(0x6600); + RfuPrepareSendBuffer(RFU_COMMAND_0x6600); Rfu.unk_fe = 0; } } @@ -1396,7 +1396,7 @@ static void sub_80FA350(void) { if (Rfu.unk_124.count == 0 && gSendCmd[0] == 0) { - RfuPrepareSendBuffer(0x6600); + RfuPrepareSendBuffer(RFU_COMMAND_0x6600); Rfu.RfuFunc = sub_80FA2B0; } } @@ -1406,15 +1406,15 @@ static void sub_80FA388(void) u8 i; u8 playerCount; - if (GetMultiplayerId() != 0) + if (GetMultiplayerId() != 0) // child { if (Rfu.unk_124.count == 0 && gSendCmd[0] == 0) { - RfuPrepareSendBuffer(0x6600); + RfuPrepareSendBuffer(RFU_COMMAND_0x6600); Rfu.RfuFunc = sub_80FA2B0; } } - else + else // parent { playerCount = GetLinkPlayerCount(); for (i = 1; i < playerCount; i++) @@ -1426,7 +1426,7 @@ static void sub_80FA388(void) { if (Rfu.unk_124.count == 0 && gSendCmd[0] == 0) { - RfuPrepareSendBuffer(0x6600); + RfuPrepareSendBuffer(RFU_COMMAND_0x6600); Rfu.RfuFunc = sub_80FA350; } } @@ -1640,9 +1640,9 @@ static void sub_80FA834(u8 taskId) if (Rfu.unk_0c == 1) { if (gReceivedRemoteLinkPlayers) - RfuPrepareSendBuffer(0x7800); + RfuPrepareSendBuffer(RFU_COMMAND_0x7800); else - RfuPrepareSendBuffer(0x7700); + RfuPrepareSendBuffer(RFU_COMMAND_0x7700); gTasks[taskId].data[0] = 101; } else @@ -1662,7 +1662,7 @@ static void sub_80FA834(u8 taskId) if (sub_80F9C50()) { Rfu.unk_5a = 0; - RfuPrepareSendBuffer(0xa100); + RfuPrepareSendBuffer(RFU_COMMAND_0xa100); gTasks[taskId].data[0]++; } } @@ -1752,7 +1752,7 @@ static void sub_80FAA94(u8 taskId) if (gSendCmd[0] == 0) { ResetBlockReceivedFlag(r4); - RfuPrepareSendBuffer(0x7800); + RfuPrepareSendBuffer(RFU_COMMAND_0x7800); gTasks[taskId].data[0]++; } break; @@ -1877,7 +1877,7 @@ static void rfu_REQ_recvData_then_sendData(void) bool32 LinkRfuMain1(void) { bool32 retval = FALSE; - Rfu.unk_ccd = 0; + Rfu.parentId = 0; rfu_LMAN_manager_entity(Random()); if (Rfu.unk_ef == 0) { @@ -1887,7 +1887,7 @@ bool32 LinkRfuMain1(void) sub_80F911C(); break; case 0: - retval = sub_80F9514(); + retval = RfuProcessEnqueuedRecvBlock(); break; case 2: rfu_REQ_recvData_then_sendData(); @@ -1909,7 +1909,7 @@ bool32 LinkRfuMain2(void) return retval; } -static void sub_80FAF1C(void) +static void CopyPlayerNameToUnameBuffer(void) { StringCopy(gHostRFUtgtUnameBuffer, gSaveBlock2Ptr->playerName); } @@ -1925,13 +1925,13 @@ void SetHostRFUtgtGname(u8 activity, u32 child_sprite_genders, u32 a2) InitHostRFUtgtGname(&gHostRFUtgtGnameBuffer, activity, a2, child_sprite_genders); } -void sub_80FAF74(bool32 a0, bool32 a1) +void SetGnameBufferWonderFlags(bool32 hasNews, bool32 hasCard) { - gHostRFUtgtGnameBuffer.unk_00.unk_00_4 = a0; - gHostRFUtgtGnameBuffer.unk_00.unk_00_5 = a1; + gHostRFUtgtGnameBuffer.unk_00.hasNews = hasNews; + gHostRFUtgtGnameBuffer.unk_00.hasCard = hasCard; } -void sub_80FAFA0(u32 type, u32 species, u32 level) +void RfuUpdatePlayerGnameStateAndSend(u32 type, u32 species, u32 level) { gHostRFUtgtGnameBuffer.type = type; gHostRFUtgtGnameBuffer.species = species; @@ -1958,7 +1958,7 @@ void sub_80FB030(u32 linkPlayerCount) u32 child_sprite_genders; s32 bm_child_slots; - if (GetHostRFUtgtGname()->activity == (0x40 | UROOM_ACTIVITY_CHAT)) + if (GetHostRFUtgtGname()->activity == (UROOM_ACTIVITY_CHAT | 0x40)) { numConnectedChildren = 0; child_sprite_genders = 0; @@ -1976,7 +1976,7 @@ void sub_80FB030(u32 linkPlayerCount) break; } } - sub_80FB008(0x45, child_sprite_genders, 0); + sub_80FB008(UROOM_ACTIVITY_CHAT | 0x40, child_sprite_genders, 0); } } @@ -2015,14 +2015,14 @@ static void sub_80FB174(void) Rfu.RfuFunc = sub_80FB154; } -static void sub_80FB184(u8 msg, u8 param_count) +static void LmanCallback_Parent2(u8 msg, u8 param_count) { u8 i; u8 r6 = 0; switch (msg) { case LMAN_MSG_INITIALIZE_COMPLETED: - Rfu.unk_04 = 2; + Rfu.state = 2; break; case LMAN_MSG_NEW_CHILD_CONNECT_DETECTED: break; @@ -2061,7 +2061,7 @@ static void sub_80FB184(u8 msg, u8 param_count) rfu_REQ_disconnect(Rfu.unk_ce7 ^ lman.acceptSlot_flag); rfu_waitREQComplete(); } - Rfu.unk_04 = 0x11; + Rfu.state = 0x11; break; case LMAN_MSG_LINK_LOSS_DETECTED_AND_START_RECOVERY: Rfu.linkLossRecoveryState = 1; @@ -2106,15 +2106,15 @@ static void sub_80FB184(u8 msg, u8 param_count) static const u8 unref_843EDF3[] = _(" あきと"); -static void sub_80FB37C(u8 msg, u8 param_count) +static void LmanCallback_Child(u8 msg, u8 param_count) { switch (msg) { case LMAN_MSG_INITIALIZE_COMPLETED: - Rfu.unk_04 = 6; + Rfu.state = 6; break; case LMAN_MSG_PARENT_FOUND: - Rfu.unk_ccd = lman.param[0]; + Rfu.parentId = lman.param[0]; break; case LMAN_MSG_SEARCH_PARENT_PERIOD_EXPIRED: break; @@ -2125,7 +2125,7 @@ static void sub_80FB37C(u8 msg, u8 param_count) RfuSetErrorStatus(2, msg); break; case LMAN_MSG_CHILD_NAME_SEND_COMPLETED: - Rfu.unk_04 = 11; + Rfu.state = 11; Rfu.unk_c85 = 0; Rfu.unk_c86 = 0; rfu_setRecvBuffer(TYPE_NI, Rfu.child_slot, &Rfu.unk_c86, 1); @@ -2201,7 +2201,7 @@ static u8 sub_80FB5A0(s32 a0) if ((a0 >> i) & 1) { struct GFtgtGname *structPtr = (void *)&gRfuLinkStatus->partner[i].gname; - if (structPtr->activity == (0x40 | UROOM_ACTIVITY_CHAT)) + if (structPtr->activity == (UROOM_ACTIVITY_CHAT | 0x40)) ret |= (1 << i); } } @@ -2209,20 +2209,20 @@ static u8 sub_80FB5A0(s32 a0) return ret; } -static void sub_80FB5EC(u8 msg, u8 param_count) +static void LmanCallback_Parent(u8 msg, u8 param_count) { u8 r1; switch (msg) { case LMAN_MSG_INITIALIZE_COMPLETED: - Rfu.unk_04 = 0x11; + Rfu.state = 0x11; break; case LMAN_MSG_NEW_CHILD_CONNECT_DETECTED: RfuSetErrorStatus(4, 0); break; case LMAN_MSG_NEW_CHILD_CONNECT_ACCEPTED: - if (GetHostRFUtgtGname()->activity == (0x40 | UROOM_ACTIVITY_CHAT) && Rfu.unk_cd9 == 0) + if (GetHostRFUtgtGname()->activity == (UROOM_ACTIVITY_CHAT | 0x40) && Rfu.unk_cd9 == 0) { u8 idx = sub_80FB5A0(lman.param[0]); if (idx != 0) @@ -2257,17 +2257,17 @@ 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()->activity != (0x40 | UROOM_ACTIVITY_CHAT) && lman.acceptCount > 1) + if (GetHostRFUtgtGname()->activity != (UROOM_ACTIVITY_CHAT | 0x40) && lman.acceptCount > 1) { r1 = 1 << sub_80F886C(lman.param[0]); rfu_REQ_disconnect(lman.acceptSlot_flag ^ r1); rfu_waitREQComplete(); } - if (Rfu.unk_04 == 0xF) - Rfu.unk_04 = 0x10; + if (Rfu.state == 0xF) + Rfu.state = 0x10; break; case LMAN_MSG_PARENT_FOUND: - Rfu.unk_ccd = lman.param[0]; + Rfu.parentId = lman.param[0]; break; case LMAN_MSG_SEARCH_PARENT_PERIOD_EXPIRED: break; @@ -2275,7 +2275,7 @@ static void sub_80FB5EC(u8 msg, u8 param_count) Rfu.child_slot = lman.param[0]; break; case LMAN_MSG_CONNECT_PARENT_FAILED: - Rfu.unk_04 = 0x12; + Rfu.state = 0x12; if (Rfu.unk_ccf < 2) { Rfu.unk_ccf++; @@ -2287,7 +2287,7 @@ static void sub_80FB5EC(u8 msg, u8 param_count) } break; case LMAN_MSG_CHILD_NAME_SEND_COMPLETED: - Rfu.unk_04 = 0xD; + Rfu.state = 0xD; RfuSetErrorStatus(3, 0); rfu_setRecvBuffer(TYPE_UNI, Rfu.child_slot, Rfu.unk_c3f, sizeof(Rfu.unk_c3f)); break; @@ -2327,7 +2327,7 @@ static void sub_80FB5EC(u8 msg, u8 param_count) } if (gRfuLinkStatus->parentChild == MODE_NEUTRAL && lman.pcswitch_flag == 0 && FuncIsActiveTask(sub_80F8B34) == TRUE) - Rfu.unk_04 = 0x11; + Rfu.state = 17; RfuSetErrorStatus(2, msg); break; @@ -2462,8 +2462,8 @@ static void sub_80FBB74(void) void sub_80FBB8C(u32 a0) { Rfu.unk_0c = 1; - sub_80FAF1C(); - rfu_LMAN_initializeManager(sub_80FB184, NULL); + CopyPlayerNameToUnameBuffer(); + rfu_LMAN_initializeManager(LmanCallback_Parent2, NULL); sRfuReqConfig = sRfuReqConfigTemplate; sRfuReqConfig.availSlot_flag = sAvailSlots[a0 - 1]; sub_80F8E74(); @@ -2472,8 +2472,8 @@ void sub_80FBB8C(u32 a0) void sub_80FBBD8(void) { Rfu.unk_0c = 0; - sub_80FAF1C(); - rfu_LMAN_initializeManager(sub_80FB37C, sub_80F8D20); + CopyPlayerNameToUnameBuffer(); + rfu_LMAN_initializeManager(LmanCallback_Child, MscCallback_Child); sub_80F8F10(); } @@ -2482,8 +2482,8 @@ void sub_80FBC00(void) if (gQuestLogState == 2 || gQuestLogState == 3) return; Rfu.unk_0c = 2; - sub_80FAF1C(); - rfu_LMAN_initializeManager(sub_80FB5EC, NULL); + CopyPlayerNameToUnameBuffer(); + rfu_LMAN_initializeManager(LmanCallback_Parent, NULL); sRfuReqConfig = sRfuReqConfigTemplate; sRfuReqConfig.linkRecovery_enable = 0; sRfuReqConfig.linkRecovery_period = 600; @@ -2524,7 +2524,7 @@ static u8 GetPartnerIndexByNameAndTrainerID(const u8 *trainerName, u16 trainerId return ret; } -static void sub_80FBCF8(u32 bmDisconnectSlot) +static void RfuReqDisconnectSlot(u32 bmDisconnectSlot) { rfu_REQ_disconnect(bmDisconnectSlot); rfu_waitREQComplete(); @@ -2538,7 +2538,7 @@ void sub_80FBD4C(const u8 *trainerName, u16 trainerId) { u8 var = GetPartnerIndexByNameAndTrainerID(trainerName, trainerId); if (var != 0xFF) - sub_80FBCF8(1 << var); + RfuReqDisconnectSlot(1 << var); } void sub_80FBD6C(u32 a0) @@ -2562,7 +2562,7 @@ static void sub_80FBDB8(u8 taskId) { if (gSendCmd[0] == 0 && !Rfu.unk_ce8) { - RfuPrepareSendBuffer(0xED00); + RfuPrepareSendBuffer(RFU_COMMAND_0xed00); gSendCmd[1] = gTasks[taskId].data[0]; gSendCmd[2] = gTasks[taskId].data[1]; Rfu.playerCount -= gUnknown_843EC41[gTasks[taskId].data[0]]; @@ -2602,7 +2602,7 @@ static void sub_80FBE80(u8 taskId) if (sub_80F8ECC()) DestroyTask(taskId); } - else if (GetHostRFUtgtGname()->activity == 0x15 || GetHostRFUtgtGname()->activity == 0x16) + else if (GetHostRFUtgtGname()->activity == UROOM_ACTIVITY_WCARD2 || GetHostRFUtgtGname()->activity == UROOM_ACTIVITY_WNEWS2) { data[15]++; } @@ -2642,30 +2642,30 @@ void sub_80FBF54(const u8 *src, u16 trainerId) data[8] = trainerId; } -static bool32 sub_80FBF98(s16 a1, struct GFtgtGname *structPtr) +static bool32 ShouldRejectPartnerConnectionBasedOnActivity(s16 activity, struct GFtgtGname *partnerGname) { - if (GetHostRFUtgtGname()->activity == (0x40 | UROOM_ACTIVITY_CHAT)) + if (GetHostRFUtgtGname()->activity == (UROOM_ACTIVITY_CHAT | 0x40)) { - if (structPtr->activity != (0x40 | UROOM_ACTIVITY_CHAT)) + if (partnerGname->activity != (UROOM_ACTIVITY_CHAT | 0x40)) return TRUE; } - else if (structPtr->activity != 0x40) + else if (partnerGname->activity != 0x40) { return TRUE; } - else if (a1 == (0x40 | UROOM_ACTIVITY_TRADE)) + else if (activity == (UROOM_ACTIVITY_TRADE | 0x40)) { - struct GFtgtGname *structPtr2 = (struct GFtgtGname *)&Rfu.unk_104.gname; - if (structPtr2->species == SPECIES_EGG) + struct GFtgtGname *myTradeGname = (struct GFtgtGname *)&Rfu.unk_104.gname; + if (myTradeGname->species == SPECIES_EGG) { - if (structPtr->species == structPtr2->species) + if (partnerGname->species == myTradeGname->species) return FALSE; else return TRUE; } - else if (structPtr->species != structPtr2->species - || structPtr->level != structPtr2->level - || structPtr->type != structPtr2->type) + else if (partnerGname->species != myTradeGname->species + || partnerGname->level != myTradeGname->level + || partnerGname->type != myTradeGname->type) { return TRUE; } @@ -2685,17 +2685,17 @@ static void sub_80FC028(u8 taskId) DestroyTask(taskId); } - if (Rfu.unk_ccd != 0 && lman.parent_child == 0) + if (Rfu.parentId != 0 && lman.parent_child == MODE_CHILD) { u16 trainerId = ReadU16(((struct GFtgtGname *)&Rfu.unk_104.gname)->unk_00.playerTrainerId); u8 id = GetPartnerIndexByNameAndTrainerID(Rfu.unk_104.uname, trainerId); if (id != 0xFF) { - if (!sub_80FBF98(gTasks[taskId].data[1], (struct GFtgtGname *)&gRfuLinkStatus->partner[id].gname)) + if (!ShouldRejectPartnerConnectionBasedOnActivity(gTasks[taskId].data[1], (struct GFtgtGname *)&gRfuLinkStatus->partner[id].gname)) { - if (gRfuLinkStatus->partner[id].slot != 0xFF && !rfu_LMAN_CHILD_connectParent(gRfuLinkStatus->partner[id].id, 0x5A)) + if (gRfuLinkStatus->partner[id].slot != 0xFF && !rfu_LMAN_CHILD_connectParent(gRfuLinkStatus->partner[id].id, 90)) { - Rfu.unk_04 = 0xA; + Rfu.state = 10; DestroyTask(taskId); } } diff --git a/src/link_rfu_3.c b/src/link_rfu_3.c index 01e0761c8..82fcffed2 100644 --- a/src/link_rfu_3.c +++ b/src/link_rfu_3.c @@ -619,10 +619,10 @@ void InitHostRFUtgtGname(struct GFtgtGname *data, u8 activity, bool32 r2, s32 ch data->playerGender = gSaveBlock2Ptr->playerGender; data->activity = activity; data->unk_0a_7 = r2; - data->unk_00.unk_00_0 = GAME_LANGUAGE; - data->unk_00.unk_01_2 = GAME_VERSION; - data->unk_00.unk_00_4 = 0; - data->unk_00.unk_00_5 = 0; + data->unk_00.language = GAME_LANGUAGE; + data->unk_00.version = GAME_VERSION; + data->unk_00.hasNews = FALSE; + data->unk_00.hasCard = FALSE; data->unk_00.unk_00_6 = 0; data->unk_00.isChampion = FlagGet(FLAG_SYS_CAN_LINK_WITH_RS); data->unk_00.hasNationalDex = IsNationalPokedexEnabled(); @@ -636,7 +636,7 @@ void InitHostRFUtgtGname(struct GFtgtGname *data, u8 activity, bool32 r2, s32 ch * Otherwise, blanks these. * ========================================================== */ -bool8 sub_80FCC3C(struct GFtgtGname *gname, u8 *uname, u8 idx) +bool8 LinkRfu_GetNameIfCompatible(struct GFtgtGname *gname, u8 *uname, u8 idx) { bool8 retVal; diff --git a/src/party_menu.c b/src/party_menu.c index c9a88f157..600350ca9 100644 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -3907,7 +3907,7 @@ static void CursorCB_Trade1(u8 taskId) u16 species2 = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES2); u16 species = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES); u8 obedience = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_OBEDIENCE); - u32 stringId = GetUnionRoomTradeMessageId(*(struct GFtgtGnameSub *)GetHostRFUtgtGname(), gUnknown_203B064, species2, gUnionRoomOfferedSpecies, gUnionRoomRequestedMonType, species, obedience); + u32 stringId = GetUnionRoomTradeMessageId(*(struct GFtgtGnameSub *)GetHostRFUtgtGname(), gPartnerTgtGnameSub, species2, gUnionRoomOfferedSpecies, gUnionRoomRequestedMonType, species, obedience); if (stringId != UR_TRADE_MSG_NONE) { diff --git a/src/trade.c b/src/trade.c index fe5f53be9..b851d2093 100644 --- a/src/trade.c +++ b/src/trade.c @@ -2746,7 +2746,7 @@ int GetUnionRoomTradeMessageId(struct GFtgtGnameSub a0, struct GFtgtGnameSub a1, u8 r4 = a0.isChampion; u8 r10 = a1.hasNationalDex; u8 r0 = a1.isChampion; - u8 r1 = a1.unk_01_2; + u8 r1 = a1.version; u8 r2; if (r1 == VERSION_FIRE_RED || r1 == VERSION_LEAF_GREEN) diff --git a/src/union_room.c b/src/union_room.c index b73f82a83..44fef871a 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -53,7 +53,7 @@ static EWRAM_DATA u8 sPlayerCurrActivity = 0; static EWRAM_DATA u8 sPlayerActivityGroupSize = 0; static EWRAM_DATA union UnkUnion_Main sUnionRoomMain = {}; static EWRAM_DATA u32 sUnref_203B060 = 0; -EWRAM_DATA struct GFtgtGnameSub gUnknown_203B064 = {}; +EWRAM_DATA struct GFtgtGnameSub gPartnerTgtGnameSub = {}; EWRAM_DATA u16 gUnionRoomOfferedSpecies = SPECIES_NONE; EWRAM_DATA u8 gUnionRoomRequestedMonType = TYPE_NORMAL; static EWRAM_DATA struct UnionRoomTrade sUnionRoomTrade = {}; @@ -73,12 +73,12 @@ static u32 sub_8116D10(struct UnkStruct_Group * group, s32 id); static void sub_8116D60(struct UnkStruct_Group * group, s32 id); static void sub_8116E1C(u8 taskId); static void ListMenuItemPrintFunc_UnionRoomGroups(u8 windowId, s32 itemId, u8 y); -static u8 sub_8116FE4(void); +static u8 GetNewLeaderCandidate(void); static void sub_8117990(void); static void sub_81179A4(void); static void sub_8117A0C(u8 taskId); -static void sub_8117F20(u8 taskId); -static void sub_81182DC(u8 taskId); +static void Task_CardOrNewsWithFriend(u8 taskId); +static void Task_CardOrNewsOverWireless(u8 taskId); static void Task_ResumeUnionRoom(u8 taskId); static u16 ReadAsU16(const u8 *data); static void ReceiveUnionRoomActivityPacket(struct UnkStruct_URoom * uRoom); @@ -86,9 +86,9 @@ static bool32 sub_8119944(struct UnkStruct_URoom * uRoom); static void Task_InitUnionRoom(u8 taskId); static u8 sub_8119B94(void); static u8 sub_8119E84(struct UnkStruct_Main4 * arg0, struct UnkStruct_Main4 * arg1, u32 arg2); -static bool32 sub_8119FB0(struct GFtgtGname * arg0, s16 arg1); -static u8 sub_811A054(struct UnkStruct_Main4 * arg0, u32 arg1); -static u8 sub_811A084(struct UnkStruct_Main4 * arg0, u32 arg1); +static bool32 GetGnameWonderFlagByLinkGroup(struct GFtgtGname * gname, s16 arg1); +static u8 CreateTask_sub_8119EB8(struct UnkStruct_Main4 * arg0, u32 linkGroup); +static u8 CreateTask_sub_8119FD8(struct UnkStruct_Main4 * arg0, u32 linkGroup); static bool32 UR_PrintFieldMessage(const u8 * str); static bool32 UR_RunTextPrinters_CheckPrinter0Active(void); static bool8 PrintOnTextbox(u8 *textState, const u8 *str); @@ -644,14 +644,14 @@ static const u8 sUnref_84570D1[] = _("{DYNAMIC 00}·{DYNAMIC 01}"); // These are functions in Emerald but inlined in FireRed -#define IntlConvPartnerUname7(dest, arg1) ({ \ - StringCopy7(dest, (arg1).unk.playerName); \ - ConvertInternationalString(dest, (arg1).unk.gname.unk_00.unk_00_0); \ +#define IntlConvPartnerUname7(dest, arg1) ({ \ + StringCopy7(dest, (arg1).unk.playerName); \ + ConvertInternationalString(dest, (arg1).unk.gname.unk_00.language); \ }) -#define IntlConvPartnerUname(dest, arg1) ({ \ - StringCopy(dest, (arg1).unk.playerName); \ - ConvertInternationalString(dest, (arg1).unk.gname.unk_00.unk_00_0); \ +#define IntlConvPartnerUname(dest, arg1) ({ \ + StringCopy(dest, (arg1).unk.playerName); \ + ConvertInternationalString(dest, (arg1).unk.gname.unk_00.language); \ }) #define CopyTrainerCardData(dest, src, _version) ({ \ @@ -761,7 +761,7 @@ static void sub_8115A68(u8 taskId) data->field_0->arr[0].groupScheduledAnim = UNION_ROOM_SPAWN_IN; data->field_0->arr[0].field_1A_1 = 0; data->field_0->arr[0].field_1B = 0; - data->field_17 = sub_811A054(data->field_4, 0xFF); + data->field_17 = CreateTask_sub_8119EB8(data->field_4, 0xFF); data->field_10 = AddWindow(&gUnknown_8456CD0); data->listWindowId = AddWindow(&gUnknown_8456CFC); data->field_11 = AddWindow(&gUnknown_8456D04); @@ -1194,7 +1194,7 @@ static u8 sub_8116524(struct UnkStruct_Main0 * arg0) } } - for (id = 0; id < 4; id++) + for (id = 0; id < RFU_CHILD_MAX; id++) Appendx1Ctox20(data->field_0->arr, &data->field_4->arr[id], 5); if (ret != 2) @@ -1291,7 +1291,7 @@ static void Task_TryJoinLinkGroup(u8 taskId) case 2: BlankUnkStruct_x1CArray(data->field_4->arr, 4); BlankUnkStruct_x20Array(data->field_0->arr, 16); - data->field_11 = sub_811A054(data->field_4, gSpecialVar_0x8004); + data->field_11 = CreateTask_sub_8119EB8(data->field_4, gSpecialVar_0x8004); data->field_C = AddWindow(&gUnknown_8456CD0); data->listWindowId = AddWindow(&gUnknown_8456D4C); data->field_D = AddWindow(&gUnknown_8456D54); @@ -1316,7 +1316,7 @@ static void Task_TryJoinLinkGroup(u8 taskId) data->state = 3; break; case 3: - id = sub_8116FE4(); + id = GetNewLeaderCandidate(); switch (id) { case 1: @@ -1522,7 +1522,7 @@ static u32 sub_8116D10(struct UnkStruct_Group * arg0, s32 id) { struct UnkStruct_x20 * structPtr = &arg0->field_0->arr[id]; - if (sPlayerCurrActivity == UROOM_ACTIVITY_TRADE && structPtr->unk.gname.unk_00.unk_01_2 != VERSION_FIRE_RED && structPtr->unk.gname.unk_00.unk_01_2 != VERSION_LEAF_GREEN) + if (sPlayerCurrActivity == UROOM_ACTIVITY_TRADE && structPtr->unk.gname.unk_00.version != VERSION_FIRE_RED && structPtr->unk.gname.unk_00.version != VERSION_LEAF_GREEN) { if (!(gSaveBlock2Ptr->specialSaveWarpFlags & CHAMPION_SAVEWARP)) return 1; @@ -1583,12 +1583,12 @@ static void sub_8116E1C(u8 taskId) case 2: BlankUnkStruct_x1CArray(data->field_4->arr, 4); BlankUnkStruct_x20Array(data->field_0->arr, 16); - data->field_11 = sub_811A054(data->field_4, 0xFF); + data->field_11 = CreateTask_sub_8119EB8(data->field_4, 0xFF); data->field_F = 0; data->state = 3; break; case 3: - if (sub_8116FE4() == 1) + if (GetNewLeaderCandidate() == 1) PlaySE(SE_PC_LOGIN); if (gTasks[taskId].data[15] == 0xFF) data->state = 10; @@ -1650,7 +1650,7 @@ static void ListMenuItemPrintFunc_UnionRoomGroups(u8 windowId, s32 itemId, u8 y) sub_811A81C(windowId, 8, y, &data->field_0->arr[itemId], color_idx, itemId); } -static u8 sub_8116FE4(void) +static u8 GetNewLeaderCandidate(void) { struct UnkStruct_Group * data = sUnionRoomMain.group; u8 ret = 0; @@ -1706,7 +1706,7 @@ static u8 sub_8116FE4(void) } } - for (id = 0; id < 4; id++) + for (id = 0; id < RFU_CHILD_MAX; id++) { if (Appendx1Ctox20(data->field_0->arr, &data->field_4->arr[id], 16) != 0xFF) ret = 1; @@ -1953,7 +1953,7 @@ static void sub_81175BC(u8 taskId) else { sub_80F8D14(); - SetHostRFUtgtGname(0x45, 0, 1); + SetHostRFUtgtGname(UROOM_ACTIVITY_CHAT | 0x40, 0, 1); } EnterUnionRoomChat(); break; @@ -2054,7 +2054,7 @@ static void sub_8117A0C(u8 taskId) sPlayerCurrActivity = data->field_18; sPlayerActivityGroupSize = 2; SetHostRFUtgtGname(data->field_18, 0, 0); - sub_80FAF74(FALSE, FALSE); + SetGnameBufferWonderFlags(FALSE, FALSE); sub_800B1F4(); OpenLink(); sub_80FBB8C(2); @@ -2071,7 +2071,7 @@ static void sub_8117A0C(u8 taskId) data->field_0->arr[0].groupScheduledAnim = UNION_ROOM_SPAWN_IN; data->field_0->arr[0].field_1A_1 = 0; data->field_0->arr[0].field_1B = 0; - data->field_17 = sub_811A054(data->field_4, 0xFF); + data->field_17 = CreateTask_sub_8119EB8(data->field_4, 0xFF); winTemplate = gUnknown_8456CFC; winTemplate.baseBlock = GetMysteryGiftBaseBlock(); @@ -2240,17 +2240,17 @@ void MEvent_CreateTask_CardOrNewsWithFriend(u32 arg0) u8 taskId; struct UnkStruct_Group * dataPtr; - taskId = CreateTask(sub_8117F20, 0); + taskId = CreateTask(Task_CardOrNewsWithFriend, 0); sUnionRoomMain.group = dataPtr = (void*)(gTasks[taskId].data); sGroup = dataPtr; dataPtr->state = 0; dataPtr->textState = 0; - dataPtr->field_12 = arg0 - 21; + dataPtr->field_12 = arg0 - UROOM_ACTIVITY_WCARD2; // 0: Card; 1: News gSpecialVar_Result = 0; } -static void sub_8117F20(u8 taskId) +static void Task_CardOrNewsWithFriend(u8 taskId) { s32 id; struct WindowTemplate winTemplate1, winTemplate2; @@ -2259,7 +2259,7 @@ static void sub_8117F20(u8 taskId) switch (data->state) { case 0: - SetHostRFUtgtGname(data->field_12 + 0x15, 0, 0); + SetHostRFUtgtGname(data->field_12 + UROOM_ACTIVITY_WCARD2, 0, 0); sub_800B1F4(); OpenLink(); sub_80FBBD8(); @@ -2274,7 +2274,7 @@ static void sub_8117F20(u8 taskId) case 2: BlankUnkStruct_x1CArray(data->field_4->arr, 4); BlankUnkStruct_x20Array(data->field_0->arr, 16); - data->field_11 = sub_811A054(data->field_4, data->field_12 + 7); + data->field_11 = CreateTask_sub_8119EB8(data->field_4, data->field_12 + LINK_GROUP_WONDER_CARD); winTemplate1 = gUnknown_8456D4C; winTemplate1.baseBlock = GetMysteryGiftBaseBlock(); @@ -2298,7 +2298,7 @@ static void sub_8117F20(u8 taskId) data->state = 3; break; case 3: - id = sub_8116FE4(); + id = GetNewLeaderCandidate(); switch (id) { case 1: @@ -2406,17 +2406,17 @@ void MEvent_CreateTask_CardOrNewsOverWireless(u32 arg0) u8 taskId; struct UnkStruct_Group * dataPtr; - taskId = CreateTask(sub_81182DC, 0); + taskId = CreateTask(Task_CardOrNewsOverWireless, 0); sUnionRoomMain.group = dataPtr = (void*)(gTasks[taskId].data); sGroup = dataPtr; dataPtr->state = 0; dataPtr->textState = 0; - dataPtr->field_12 = arg0 - 21; + dataPtr->field_12 = arg0 - UROOM_ACTIVITY_WCARD2; // 0: Card; 1: News gSpecialVar_Result = 0; } -static void sub_81182DC(u8 taskId) +static void Task_CardOrNewsOverWireless(u8 taskId) { s32 id; struct WindowTemplate winTemplate; @@ -2440,7 +2440,7 @@ static void sub_81182DC(u8 taskId) case 2: BlankUnkStruct_x1CArray(data->field_4->arr, 4); BlankUnkStruct_x20Array(data->field_0->arr, 16); - data->field_11 = sub_811A084(data->field_4, data->field_12 + 7); + data->field_11 = CreateTask_sub_8119FD8(data->field_4, data->field_12 + LINK_GROUP_WONDER_CARD); if (data->field_13 != 0) { @@ -2460,7 +2460,7 @@ static void sub_81182DC(u8 taskId) data->state = 3; break; case 3: - id = sub_8116FE4(); + id = GetNewLeaderCandidate(); switch (id) { case 1: @@ -2476,7 +2476,7 @@ static void sub_81182DC(u8 taskId) { if (data->field_0->arr[0].groupScheduledAnim == UNION_ROOM_SPAWN_IN && !data->field_0->arr[0].unk.gname.unk_0a_7) { - if (sub_8119FB0(&data->field_0->arr[0].unk.gname, data->field_12 + 7)) + if (GetGnameWonderFlagByLinkGroup(&data->field_0->arr[0].unk.gname, data->field_12 + LINK_GROUP_WONDER_CARD)) { data->field_F = 0; data->field_14 = 0; @@ -2608,7 +2608,7 @@ static u16 ReadAsU16(const u8 *ptr) return (ptr[1] << 8) | (ptr[0]); } -static void sub_8118664(u32 nextState, const u8 *src) +static void UnionRoom_ScheduleFieldMessageWithFollowupState(u32 nextState, const u8 *src) { struct UnkStruct_URoom * data = sUnionRoomMain.uRoom; @@ -2666,7 +2666,7 @@ static void Task_ResumeUnionRoom(u8 taskId) break; case 2: SetHostRFUtgtGname(0x40, 0, 0); - sub_80FAFA0(sUnionRoomTrade.type, sUnionRoomTrade.playerSpecies, sUnionRoomTrade.playerLevel); + RfuUpdatePlayerGnameStateAndSend(sUnionRoomTrade.type, sUnionRoomTrade.playerSpecies, sUnionRoomTrade.playerLevel); sub_800B1F4(); OpenLink(); sub_80FBC00(); @@ -2678,7 +2678,7 @@ static void Task_ResumeUnionRoom(u8 taskId) break; case 3: if ((GetPartyMenuType() == PARTY_MENU_TYPE_UNION_ROOM_REGISTER - || GetPartyMenuType() == PARTY_MENU_TYPE_UNION_ROOM_TRADE) + || GetPartyMenuType() == PARTY_MENU_TYPE_UNION_ROOM_TRADE) && sUnionRoomTrade.field_0 != 0) { id = GetCursorSelectionMonId(); @@ -2689,12 +2689,12 @@ static void Task_ResumeUnionRoom(u8 taskId) if (id >= PARTY_SIZE) { ResetUnionRoomTrade(&sUnionRoomTrade); - sub_80FAFA0(0, 0, 0); + RfuUpdatePlayerGnameStateAndSend(0, 0, 0); sub_811868C(gUnknown_8458D54); } else if (!RegisterTradeMonAndGetIsEgg(GetCursorSelectionMonId(), &sUnionRoomTrade)) { - sub_8118664(0x34, gUnknown_8458CD4); + UnionRoom_ScheduleFieldMessageWithFollowupState(52, gURText_PleaseChooseTypeOfMon); } else { @@ -2781,7 +2781,7 @@ static void Task_ResumeUnionRoom(u8 taskId) case 4: data->state = 11; sub_811B298(); - sub_80FAFA0(0, 0, 0); + RfuUpdatePlayerGnameStateAndSend(0, 0, 0); sub_80FB008(0x13 | 0x40, sub_811B2D8(data), 0); break; } @@ -2810,7 +2810,7 @@ static void Task_ResumeUnionRoom(u8 taskId) data->state = 25; break; case 2: - sub_8118664(0x13, gStringVar4); + UnionRoom_ScheduleFieldMessageWithFollowupState(19, gStringVar4); break; } break; @@ -2827,7 +2827,7 @@ static void Task_ResumeUnionRoom(u8 taskId) if (sub_80FBB0C() == TRUE) sub_811868C(gUnknown_8457F90); else - sub_8118664(30, gUnknown_8457F90); + UnionRoom_ScheduleFieldMessageWithFollowupState(30, gUnknown_8457F90); sPlayerCurrActivity = 0x40; break; @@ -2844,7 +2844,7 @@ static void Task_ResumeUnionRoom(u8 taskId) if (!FuncIsActiveTask(sub_8117280)) { if (sPlayerCurrActivity == (UROOM_ACTIVITY_TRADE | 0x40)) - sub_8118664(31, gUnknown_84578BC); + UnionRoom_ScheduleFieldMessageWithFollowupState(31, gUnknown_84578BC); else data->state = 5; } @@ -2860,7 +2860,7 @@ static void Task_ResumeUnionRoom(u8 taskId) case 5: id = sub_811AA24(&data->field_0->arr[taskData[1]]); playerGender = GetUnionRoomPlayerGender(taskData[1], data->field_0); - sub_8118664(6, gUnknown_8457B04[id][playerGender]); + UnionRoom_ScheduleFieldMessageWithFollowupState(6, gURText_FriendPromptsForActivity[id][playerGender]); break; case 6: var5 = ListMenuHandler_AllItemsAvailable(&data->textState, &data->topListMenuWindowId, &data->topListMenuListMenuId, &sWindowTemplate_InviteToActivity, &sListMenuTemplate_InviteToActivity); @@ -2887,7 +2887,7 @@ static void Task_ResumeUnionRoom(u8 taskId) sPlayerActivityGroupSize = (u32)(var5) >> 8; if (sPlayerCurrActivity == (UROOM_ACTIVITY_BATTLE | 0x40) && !HasAtLeastTwoMonsOfLevel30OrLower()) { - sub_8118664(5, gUnknown_845847C); + UnionRoom_ScheduleFieldMessageWithFollowupState(5, gUnknown_845847C); } else { @@ -2957,7 +2957,7 @@ static void Task_ResumeUnionRoom(u8 taskId) case 7: id = sub_811AA24(&data->field_0->arr[taskData[1]]); playerGender = GetUnionRoomPlayerGender(taskData[1], data->field_0); - sub_8118664(6, gUnknown_8457B04[id][playerGender]); + UnionRoom_ScheduleFieldMessageWithFollowupState(6, gURText_FriendPromptsForActivity[id][playerGender]); break; case 40: if (PrintOnTextbox(&data->textState, gStringVar4)) @@ -3024,7 +3024,7 @@ static void Task_ResumeUnionRoom(u8 taskId) if (sub_80FBB0C() == TRUE) sub_811868C(gUnknown_84585E8[playerGender]); else - sub_8118664(30, gUnknown_84585E8[playerGender]); + UnionRoom_ScheduleFieldMessageWithFollowupState(30, gUnknown_84585E8[playerGender]); break; case 3: data->state = 22; @@ -3040,7 +3040,7 @@ static void Task_ResumeUnionRoom(u8 taskId) if (sub_80FBB0C() == TRUE) sub_811868C(gUnknown_84585E8[playerGender]); else - sub_8118664(30, gUnknown_84585E8[playerGender]); + UnionRoom_ScheduleFieldMessageWithFollowupState(30, gUnknown_84585E8[playerGender]); } if (gReceivedRemoteLinkPlayers != 0) data->state = 16; @@ -3089,7 +3089,7 @@ static void Task_ResumeUnionRoom(u8 taskId) } break; case 35: - sub_8118664(9, gStringVar4); + UnionRoom_ScheduleFieldMessageWithFollowupState(9, gStringVar4); break; case 9: switch (sub_811A14C(&data->textState, FALSE)) @@ -3147,7 +3147,7 @@ static void Task_ResumeUnionRoom(u8 taskId) if (gReceivedRemoteLinkPlayers == 0) { sPlayerCurrActivity = 0x40; - sub_8118664(37, gStringVar4); + UnionRoom_ScheduleFieldMessageWithFollowupState(37, gStringVar4); memset(data->playerSendBuffer, 0, sizeof(data->playerSendBuffer)); data->recvActivityRequest[0] = 0; data->partnerYesNoResponse = 0; @@ -3159,7 +3159,7 @@ static void Task_ResumeUnionRoom(u8 taskId) break; case 13: GetURoomActivityStartMsg(gStringVar4, sPlayerCurrActivity | 0x40); - sub_8118664(14, gStringVar4); + UnionRoom_ScheduleFieldMessageWithFollowupState(14, gStringVar4); break; case 14: sub_800AB9C(); @@ -3208,7 +3208,7 @@ static void Task_ResumeUnionRoom(u8 taskId) ConvertIntToDecimalStringN(gStringVar2, GetHostRFUtgtGname()->level, STR_CONV_MODE_LEFT_ALIGN, 3); StringExpandPlaceholders(gStringVar4, gUnknown_8458DBC); } - sub_8118664(44, gStringVar4); + UnionRoom_ScheduleFieldMessageWithFollowupState(44, gStringVar4); } break; case 43: @@ -3229,10 +3229,10 @@ static void Task_ResumeUnionRoom(u8 taskId) switch (var5) { case 1: // REGISTER - sub_8118664(53, gUnknown_8458D1C); + UnionRoom_ScheduleFieldMessageWithFollowupState(53, gUnknown_8458D1C); break; case 2: // INFO - sub_8118664(47, gUnknown_8458B44); + UnionRoom_ScheduleFieldMessageWithFollowupState(47, gUnknown_8458B44); break; } } @@ -3260,7 +3260,7 @@ static void Task_ResumeUnionRoom(u8 taskId) case -2: case 18: ResetUnionRoomTrade(&sUnionRoomTrade); - sub_80FAFA0(0, 0, 0); + RfuUpdatePlayerGnameStateAndSend(0, 0, 0); sub_811868C(gUnknown_8458D54); break; default: @@ -3271,7 +3271,7 @@ static void Task_ResumeUnionRoom(u8 taskId) } break; case 55: - sub_80FAFA0(sUnionRoomTrade.type, sUnionRoomTrade.playerSpecies, sUnionRoomTrade.playerLevel); + RfuUpdatePlayerGnameStateAndSend(sUnionRoomTrade.type, sUnionRoomTrade.playerSpecies, sUnionRoomTrade.playerLevel); sub_811868C(gUnknown_8458D78); break; case 44: @@ -3290,7 +3290,7 @@ static void Task_ResumeUnionRoom(u8 taskId) case 56: if (PrintOnTextbox(&data->textState, gUnknown_8458E10)) { - sub_80FAFA0(0, 0, 0); + RfuUpdatePlayerGnameStateAndSend(0, 0, 0); ResetUnionRoomTrade(&sUnionRoomTrade); sub_811B258(TRUE); data->state = 4; @@ -3321,18 +3321,18 @@ static void Task_ResumeUnionRoom(u8 taskId) { case UR_TRADE_MATCH: IntlConvPartnerUname(gStringVar1, data->field_0->arr[var5]); - sub_8118664(49, gUnknown_8458E70); + UnionRoom_ScheduleFieldMessageWithFollowupState(49, gUnknown_8458E70); taskData[1] = var5; break; case UR_TRADE_NOTYPE: IntlConvPartnerUname(gStringVar1, data->field_0->arr[var5]); StringCopy(gStringVar2, gTypeNames[data->field_0->arr[var5].unk.gname.type]); - sub_8118664(46, gUnknown_8458ED0); + UnionRoom_ScheduleFieldMessageWithFollowupState(46, gUnknown_8458ED0); break; case UR_TRADE_NOEGG: IntlConvPartnerUname(gStringVar1, data->field_0->arr[var5]); StringCopy(gStringVar2, gTypeNames[data->field_0->arr[var5].unk.gname.type]); - sub_8118664(46, gUnknown_8458F04); + UnionRoom_ScheduleFieldMessageWithFollowupState(46, gUnknown_8458F04); break; } break; @@ -3356,7 +3356,7 @@ static void Task_ResumeUnionRoom(u8 taskId) if (PrintOnTextbox(&data->textState, gUnknown_8458D1C)) { sUnionRoomTrade.field_0 = 2; - memcpy(&gUnknown_203B064, &data->field_0->arr[taskData[1]].unk.gname.unk_00, sizeof(gUnknown_203B064)); + memcpy(&gPartnerTgtGnameSub, &data->field_0->arr[taskData[1]].unk.gname.unk_00, sizeof(gPartnerTgtGnameSub)); gUnionRoomRequestedMonType = data->field_0->arr[taskData[1]].unk.gname.type; gUnionRoomOfferedSpecies = data->field_0->arr[taskData[1]].unk.gname.species; gFieldCallback = sub_807DCE4; @@ -3369,7 +3369,7 @@ static void Task_ResumeUnionRoom(u8 taskId) sPlayerCurrActivity = UROOM_ACTIVITY_TRADE | 0x40; sub_80FC114(data->field_0->arr[taskData[1]].unk.playerName, &data->field_0->arr[taskData[1]].unk.gname, UROOM_ACTIVITY_TRADE | 0x40); IntlConvPartnerUname(gStringVar1, data->field_0->arr[taskData[1]]); - UR_PrintFieldMessage(gUnknown_8457A34[2]); + UR_PrintFieldMessage(gURText_PleaseWaitMsgs[2]); data->state = 25; break; case 26: @@ -3462,7 +3462,7 @@ static void Task_InitUnionRoom(u8 taskId) structPtr->state = 1; break; case 1: - SetHostRFUtgtGname(0xC, 0, 0); + SetHostRFUtgtGname(UROOM_ACTIVITY_SEARCH, 0, 0); sub_800B1F4(); OpenLink(); sub_80FBC00(); @@ -3540,7 +3540,7 @@ static u8 sub_8119B94(void) struct UnkStruct_URoom * structPtr = sUnionRoomMain.uRoom; s32 r7 = 0; - for (i = 0; i < 4; i++) + for (i = 0; i < RFU_CHILD_MAX; i++) { if (AreUnkSharedObjectsDifferent(&structPtr->field_C->arr[i].unk0, &sUnkStruct_Shared_Dummy) == TRUE) { @@ -3600,7 +3600,7 @@ static u8 sub_8119B94(void) } } } - for (i = 0; i < 4; i++) + for (i = 0; i < RFU_CHILD_MAX; i++) { if (Appendx1Ctox20(&structPtr->field_0->arr[0], &structPtr->field_4->arr[i], 8) != 0xFF) r7 = 1; @@ -3618,12 +3618,12 @@ static void Task_SearchForChildOrParent(u8 taskId) for (i = 0; i < RFU_CHILD_MAX; i++) { - parent_child = sub_80FCC3C(&sp0.gname, sp0.playerName, i); + parent_child = LinkRfu_GetNameIfCompatible(&sp0.gname, sp0.playerName, i); if (!IsPartnerActivityAcceptable(sp0.gname.activity, gTasks[taskId].data[4])) { sp0 = sUnkStruct_Shared_Dummy; } - if (sp0.gname.unk_00.unk_00_0 == 1) + if (sp0.gname.unk_00.language == LANGUAGE_JAPANESE) { sp0 = sUnkStruct_Shared_Dummy; } @@ -3662,9 +3662,9 @@ static void sub_8119EB8(u8 taskId) s32 i, j; struct UnkStruct_Main4 ** ptr = (void*) gTasks[taskId].data; - for (i = 0; i < 4; i++) + for (i = 0; i < RFU_CHILD_MAX; i++) { - sub_80FCC3C(&ptr[0]->arr[i].unk0.gname, ptr[0]->arr[i].unk0.playerName, i); + LinkRfu_GetNameIfCompatible(&ptr[0]->arr[i].unk0.gname, ptr[0]->arr[i].unk0.playerName, i); if (!IsPartnerActivityAcceptable(ptr[0]->arr[i].unk0.gname.activity, gTasks[taskId].data[2])) { ptr[0]->arr[i].unk0 = sUnkStruct_Shared_Dummy; @@ -3680,11 +3680,11 @@ static void sub_8119EB8(u8 taskId) } } -static bool32 sub_8119FB0(struct GFtgtGname * arg0, s16 arg1) +static bool32 GetGnameWonderFlagByLinkGroup(struct GFtgtGname * gname, s16 linkGroup) { - if (arg1 == 7) + if (linkGroup == LINK_GROUP_WONDER_CARD) { - if (!arg0->unk_00.unk_00_5) + if (!gname->unk_00.hasCard) { return FALSE; } @@ -3693,9 +3693,9 @@ static bool32 sub_8119FB0(struct GFtgtGname * arg0, s16 arg1) return TRUE; } } - else if (arg1 == 8) + else if (linkGroup == LINK_GROUP_WONDER_NEWS) { - if (!arg0->unk_00.unk_00_4) + if (!gname->unk_00.hasNews) { return FALSE; } @@ -3715,30 +3715,30 @@ static void sub_8119FD8(u8 taskId) s32 i; struct UnkStruct_Main4 ** ptr = (void*) gTasks[taskId].data; - for (i = 0; i < 4; i++) + for (i = 0; i < RFU_CHILD_MAX; i++) { if (sub_80FCCF4(&ptr[0]->arr[i].unk0.gname, ptr[0]->arr[i].unk0.playerName, i)) { - sub_8119FB0(&ptr[0]->arr[i].unk0.gname, gTasks[taskId].data[2]); + GetGnameWonderFlagByLinkGroup(&ptr[0]->arr[i].unk0.gname, gTasks[taskId].data[2]); } ptr[0]->arr[i].active = AreUnkSharedObjectsDifferent(&ptr[0]->arr[i].unk0, &sUnkStruct_Shared_Dummy); } } -static u8 sub_811A054(struct UnkStruct_Main4 * a0, u32 a1) +static u8 CreateTask_sub_8119EB8(struct UnkStruct_Main4 * main4, u32 linkGroup) { u8 taskId = CreateTask(sub_8119EB8, 0); struct UnkStruct_Main4 ** ptr = (void*) gTasks[taskId].data; - ptr[0] = a0; - gTasks[taskId].data[2] = a1; + ptr[0] = main4; + gTasks[taskId].data[2] = linkGroup; return taskId; } -static u8 sub_811A084(struct UnkStruct_Main4 * a0, u32 a1) +static u8 CreateTask_sub_8119FD8(struct UnkStruct_Main4 * main4, u32 a1) { u8 taskId = CreateTask(sub_8119FD8, 0); struct UnkStruct_Main4 ** ptr = (void*) gTasks[taskId].data; - ptr[0] = a0; + ptr[0] = main4; gTasks[taskId].data[2] = a1; return taskId; } @@ -4029,7 +4029,7 @@ static void BlankUnkStruct_x1CArray(struct UnkStruct_x1C * arg0, u8 count) { s32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < RFU_CHILD_MAX; i++) { arg0[i].unk0 = sUnkStruct_Shared_Dummy; arg0[i].active = FALSE; @@ -4073,7 +4073,7 @@ static bool32 AreUnionRoomPlayerGnamesDifferent(struct UnkStruct_Shared * arg0, return TRUE; } - for (i = 0; i < 4; i++) + for (i = 0; i < RFU_CHILD_MAX; i++) { if (arg0->gname.child_sprite_gender[i] != arg1->gname.child_sprite_gender[i]) { @@ -4099,7 +4099,7 @@ static u32 sub_811A748(struct UnkStruct_x20 * arg0, struct UnkStruct_x1C * arg1) u8 result = 0xFF; s32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < RFU_CHILD_MAX; i++) { if (arg1[i].active && !AreUnkSharedObjectsDifferent(&arg0->unk, &arg1[i].unk0)) { @@ -4234,7 +4234,7 @@ static s32 sub_811AA5C(struct UnkStruct_Main0 * arg0, u8 arg1, u8 arg2, u32 play } else { - UR_PrintFieldMessage(gUnknown_8457A34[r2]); + UR_PrintFieldMessage(gURText_PleaseWaitMsgs[r2]); return 1; } } @@ -4287,7 +4287,7 @@ static void TradeBoardPrintItemInfo(u8 windowId, u8 y, struct GFtgtGname * gname UR_AddTextPrinterParameterized(windowId, 2, uname, 8, y, colorIdx); if (species == SPECIES_EGG) { - UR_AddTextPrinterParameterized(windowId, 2, gUnknown_8458FBC, 0x44, y, colorIdx); + UR_AddTextPrinterParameterized(windowId, 2, gText_EggTrade, 0x44, y, colorIdx); } else { @@ -4611,7 +4611,7 @@ static void sub_811B258(bool32 arg0) sPlayerCurrActivity = 0; if (arg0) { - sub_80FAFA0(sUnionRoomTrade.type, sUnionRoomTrade.playerSpecies, sUnionRoomTrade.playerLevel); + RfuUpdatePlayerGnameStateAndSend(sUnionRoomTrade.type, sUnionRoomTrade.playerSpecies, sUnionRoomTrade.playerLevel); sub_80FB008(0x40, 0, 0); } } diff --git a/src/union_room_battle.c b/src/union_room_battle.c index 4ef01a684..0f38206ac 100644 --- a/src/union_room_battle.c +++ b/src/union_room_battle.c @@ -13,15 +13,16 @@ #include "text_window.h" #include "union_room.h" #include "window.h" +#include "constants/union_room.h" -struct UnkStruct_203B08C +struct UnionRoomBattleWork { - s16 a0; + s16 textState; }; -static EWRAM_DATA struct UnkStruct_203B08C * gUnknown_203B08C = NULL; +static EWRAM_DATA struct UnionRoomBattleWork * sWork = NULL; -static const struct BgTemplate gUnknown_8457194[] = { +static const struct BgTemplate sBgTemplates[] = { { .bg = 0, .charBaseIndex = 3, @@ -29,7 +30,7 @@ static const struct BgTemplate gUnknown_8457194[] = { } }; -static const struct WindowTemplate gUnknown_8457198[] = { +static const struct WindowTemplate sWindowTemplates[] = { { .bg = 0, .tilemapLeft = 2, @@ -43,7 +44,7 @@ static const struct WindowTemplate gUnknown_8457198[] = { static const u8 gUnknown_84571A8[] = {1, 2, 3}; -static void sub_811C04C(void) +static void SetUpPartiesAndStartBattle(void) { s32 i; sub_81173C0(BATTLE_TYPE_LINK | BATTLE_TYPE_TRAINER); @@ -65,7 +66,7 @@ static void sub_811C04C(void) SetMainCallback2(CB2_InitBattle); } -static void sub_811C0E0(u8 windowId, const u8 * str, u8 x, u8 y, s32 speed) +static void UnionRoomBattle_CreateTextPrinter(u8 windowId, const u8 * str, u8 x, u8 y, s32 speed) { s32 letterSpacing = 1; s32 lineSpacing = 1; @@ -73,13 +74,13 @@ static void sub_811C0E0(u8 windowId, const u8 * str, u8 x, u8 y, s32 speed) AddTextPrinterParameterized4(windowId, 3, x, y, letterSpacing, lineSpacing, gUnknown_84571A8, speed, str); } -static bool32 sub_811C150(s16 * state, const u8 * str, s32 speed) +static bool32 UnionRoomBattle_PrintTextOnWindow0(s16 * state, const u8 * str, s32 speed) { switch (*state) { case 0: DrawTextBorderOuter(0, 0x001, 0xD); - sub_811C0E0(0, str, 0, 2, speed); + UnionRoomBattle_CreateTextPrinter(0, str, 0, 2, speed); PutWindowTilemap(0); CopyWindowToVram(0, 3); (*state)++; @@ -95,7 +96,7 @@ static bool32 sub_811C150(s16 * state, const u8 * str, s32 speed) return FALSE; } -static void sub_811C1B4(void) +static void VBlankCB_UnionRoomBattle(void) { LoadOam(); ProcessSpriteCopyRequests(); @@ -108,14 +109,14 @@ void CB2_UnionRoomBattle(void) { case 0: SetGpuReg(REG_OFFSET_DISPCNT, 0x0000); - gUnknown_203B08C = AllocZeroed(sizeof(struct UnkStruct_203B08C)); + sWork = AllocZeroed(sizeof(struct UnionRoomBattleWork)); ResetSpriteData(); FreeAllSpritePalettes(); ResetTasks(); ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, gUnknown_8457194, 1); + InitBgsFromTemplates(0, sBgTemplates, 1); ResetTempTileDataBuffers(); - if (!InitWindows(gUnknown_8457198)) + if (!InitWindows(sWindowTemplates)) { return; } @@ -126,11 +127,11 @@ void CB2_UnionRoomBattle(void) FillBgTilemapBufferRect(0, 0, 0, 0, 30, 20, 0xF); TextWindow_SetStdFrame0_WithPal(0, 1, 0xD0); Menu_LoadStdPal(); - SetVBlankCallback(sub_811C1B4); + SetVBlankCallback(VBlankCB_UnionRoomBattle); gMain.state++; break; case 1: - if (sub_811C150(&gUnknown_203B08C->a0, gText_CommStandbyAwaitingOtherPlayer, 0)) + if (UnionRoomBattle_PrintTextOnWindow0(&sWork->textState, gText_CommStandbyAwaitingOtherPlayer, 0)) { gMain.state++; } @@ -146,11 +147,11 @@ void CB2_UnionRoomBattle(void) memset(gBlockSendBuffer, 0, 0x20); if (gSelectedOrderFromParty[0] == -gSelectedOrderFromParty[1]) { - gBlockSendBuffer[0] = 0x52; + gBlockSendBuffer[0] = UROOM_ACTIVITY_DECLINE | 0x40; } else { - gBlockSendBuffer[0] = 0x51; + gBlockSendBuffer[0] = UROOM_ACTIVITY_ACCEPT | 0x40; } SendBlock(0, gBlockSendBuffer, 0x20); gMain.state++; @@ -159,7 +160,7 @@ void CB2_UnionRoomBattle(void) case 4: if (GetBlockReceivedStatus() == 3) { - if (gBlockRecvBuffer[0][0] == 0x51 && gBlockRecvBuffer[1][0] == 0x51) + if (gBlockRecvBuffer[0][0] == (UROOM_ACTIVITY_ACCEPT | 0x40) && gBlockRecvBuffer[1][0] == (UROOM_ACTIVITY_ACCEPT | 0x40)) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); gMain.state = 50; @@ -167,7 +168,7 @@ void CB2_UnionRoomBattle(void) else { sub_800AAC0(); - if (gBlockRecvBuffer[GetMultiplayerId()][0] == 0x52) + if (gBlockRecvBuffer[GetMultiplayerId()][0] == (UROOM_ACTIVITY_DECLINE | 0x40)) { gMain.state = 6; } @@ -189,7 +190,7 @@ void CB2_UnionRoomBattle(void) case 51: if (IsLinkTaskFinished()) { - SetMainCallback2(sub_811C04C); + SetMainCallback2(SetUpPartiesAndStartBattle); } break; case 6: @@ -199,7 +200,7 @@ void CB2_UnionRoomBattle(void) } break; case 7: - if (sub_811C150(&gUnknown_203B08C->a0, gText_RefusedBattle, 1)) + if (UnionRoomBattle_PrintTextOnWindow0(&sWork->textState, gText_RefusedBattle, 1)) { SetMainCallback2(CB2_ReturnToField); } @@ -211,7 +212,7 @@ void CB2_UnionRoomBattle(void) } break; case 9: - if (sub_811C150(&gUnknown_203B08C->a0, gText_BattleWasRefused, 1)) + if (UnionRoomBattle_PrintTextOnWindow0(&sWork->textState, gText_BattleWasRefused, 1)) { SetMainCallback2(CB2_ReturnToField); } diff --git a/src/union_room_message.c b/src/union_room_message.c index 247c1046d..0edef7b04 100644 --- a/src/union_room_message.c +++ b/src/union_room_message.c @@ -125,6 +125,7 @@ const u8 *const gUnknown_8457754[] = { ALIGNED(4) const u8 gUnknown_845777C[] = _("The WIRELESS COMMUNICATION\nSYSTEM link has been established."); ALIGNED(4) const u8 gUnknown_84577BC[] = _("The WIRELESS COMMUNICATION\nSYSTEM link has been dropped…"); + ALIGNED(4) const u8 gUnknown_84577F8[] = _("The link with your friend has been\ndropped…"); ALIGNED(4) const u8 gUnknown_8457824[] = _("{STR_VAR_1} replied, “No…”"); @@ -156,7 +157,7 @@ ALIGNED(4) const u8 gUnknown_84578E4[] = _("Communicating{PAUSE 15}.{PAUSE 15}.{ ALIGNED(4) const u8 gUnknown_8457950[] = _("Communicating with {STR_VAR_1}{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.\n{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}."); ALIGNED(4) const u8 gUnknown_84579BC[] = _("Please wait a while{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.\n{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}."); -const u8 *const gUnknown_8457A34[] = { +const u8 *const gURText_PleaseWaitMsgs[] = { gUnknown_84578E4, gUnknown_8457950, gUnknown_84579BC @@ -167,7 +168,7 @@ ALIGNED(4) const u8 gUnknown_8457A70[] = _("Hello!\nWould you like to do somethi ALIGNED(4) const u8 gUnknown_8457A98[] = _("{STR_VAR_1}: Hiya, we meet again!\nWhat are you up for this time?"); ALIGNED(4) const u8 gUnknown_8457AD0[] = _("{STR_VAR_1}: Oh! {PLAYER}, hello!\nWould you like to do something?"); -const u8 *const gUnknown_8457B04[][2] = { +const u8 *const gURText_FriendPromptsForActivity[][2] = { { gUnknown_8457A40, gUnknown_8457A70 @@ -418,7 +419,8 @@ ALIGNED(4) const u8 gUnknown_8458AB8[] = _("Welcome to the TRADING BOARD.\pYou m ALIGNED(4) const u8 gUnknown_8458B44[] = _("This TRADING BOARD is used for\noffering a POKéMON for a trade.\pAll you need to do is register a\nPOKéMON for a trade.\pAnother TRAINER may offer a party\nPOKéMON in return for the trade.\pWe hope you will register POKéMON\nand trade them with many, many\lother TRAINERS.\pWould you like to register one of\nyour POKéMON?"); ALIGNED(4) const u8 gUnref_ThankYouForComing_JP[] = _("こうかんけいじばん の とうろくが\nかんりょう しました\pごりよう ありがとう\nございました!\p"); ALIGNED(4) const u8 gUnref_NoOneRegisteredMon[] = _("けいじばんに だれも ポケモンを\nとうろく していません\p\n"); -ALIGNED(4) const u8 gUnknown_8458CD4[] = _("Please choose the type of POKéMON\nthat you would like in the trade.\n"); + +ALIGNED(4) const u8 gURText_PleaseChooseTypeOfMon[] = _("Please choose the type of POKéMON\nthat you would like in the trade.\n"); ALIGNED(4) const u8 gUnknown_8458D1C[] = _("Which of your party POKéMON will\nyou offer in trade?\p"); ALIGNED(4) const u8 gUnknown_8458D54[] = _("Registration has been canceled.\p"); ALIGNED(4) const u8 gUnknown_8458D78[] = _("Registration has been completed.\p"); @@ -442,7 +444,7 @@ const u8 *const gUnknown_8458F94[] = { }; ALIGNED(4) const u8 gUnknown_8458F9C[] = _("Your trade offer was rejected.\p"); -ALIGNED(4) const u8 gUnknown_8458FBC[] = _("EGG TRADE"); +ALIGNED(4) const u8 gText_EggTrade[] = _("EGG TRADE"); ALIGNED(4) const u8 gUnknown_8458FC8[] = _("{DPAD_UPDOWN}CHOOSE {A_BUTTON}JOIN {B_BUTTON}CANCEL"); ALIGNED(4) const u8 gUnknown_8458FE4[] = _("Please choose a TRAINER."); |