From 5b526906e1dc4b3dd55cc739670836718a90dff7 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Dec 2017 12:07:20 -0500 Subject: [PATCH] through sub_800F0F8 --- asm/link_rfu.s | 130 --------------------------------------------- include/librfu.h | 1 + include/link_rfu.h | 6 ++- src/link_rfu.c | 72 ++++++++++++++++++++++++- 4 files changed, 76 insertions(+), 133 deletions(-) diff --git a/asm/link_rfu.s b/asm/link_rfu.s index 5a325f2013..ff7b2caa18 100644 --- a/asm/link_rfu.s +++ b/asm/link_rfu.s @@ -5,136 +5,6 @@ .text - thumb_func_start sub_800F0B8 -sub_800F0B8: @ 800F0B8 - push {r4,lr} - ldr r0, =gUnknown_03007890 - ldr r0, [r0] - ldrb r0, [r0, 0x6] - cmp r0, 0 - bne _0800F0CC -_0800F0C4: - movs r0, 0 - b _0800F0EC - .pool -_0800F0CC: - movs r3, 0 - ldr r4, =gRecvCmds -_0800F0D0: - movs r2, 0 - lsls r0, r3, 4 - adds r1, r0, r4 -_0800F0D6: - ldrh r0, [r1] - cmp r0, 0 - bne _0800F0C4 - adds r1, 0x2 - adds r2, 0x1 - cmp r2, 0x6 - ble _0800F0D6 - adds r3, 0x1 - cmp r3, 0x4 - ble _0800F0D0 - movs r0, 0x1 -_0800F0EC: - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_800F0B8 - - thumb_func_start sub_800F0F8 -sub_800F0F8: @ 800F0F8 - push {r4-r6,lr} - ldr r6, =gUnknown_03005000 - ldrh r0, [r6, 0x4] - cmp r0, 0x13 - bhi _0800F118 - bl rfu_REQ_recvData - bl rfu_waitREQComplete - movs r0, 0 - bl rfu_REQ_sendData_wrapper - b _0800F1D2 - .pool -_0800F118: - ldr r0, =0x00000cdb - adds r1, r6, r0 - ldrb r0, [r1] - movs r0, 0 - strb r0, [r1] - ldr r0, =0x00000ce2 - adds r1, r6, r0 - ldr r0, =gUnknown_03007890 - ldr r0, [r0] - ldrb r1, [r1] - ldrb r0, [r0, 0x2] - ands r0, r1 - cmp r0, r1 - bne _0800F1D2 - cmp r0, 0 - beq _0800F1D2 - ldr r1, =0x00000cdc - adds r0, r6, r1 - ldrb r0, [r0] - adds r5, r0, 0 - cmp r5, 0 - bne _0800F1C8 - ldr r0, =0x00000ce3 - adds r4, r6, r0 - ldrb r0, [r4] - cmp r0, 0 - beq _0800F1A8 - bl sub_8011D6C - strb r5, [r4] - ldr r1, =0x00000ce4 - adds r0, r6, r1 - ldrb r0, [r0] - cmp r0, 0x1 - bne _0800F18C - movs r4, 0x80 - lsls r4, 8 - movs r0, 0x2 - adds r1, r4, 0 - bl sub_8011A64 - adds r0, r4, 0 - bl sub_8011170 - b _0800F1D2 - .pool -_0800F18C: - ldr r0, =gUnknown_03004140 - ldrb r4, [r0] - cmp r4, 0 - bne _0800F1A8 - bl sub_800EDD4 - ldr r0, =gReceivedRemoteLinkPlayers - strb r4, [r0] - b _0800F1D2 - .pool -_0800F1A8: - bl sub_800EFB0 - ldr r0, =gUnknown_03005000 - ldr r1, =0x00000cda - adds r0, r1 - ldrb r0, [r0] - bl rfu_UNI_readySendData - movs r0, 0x1 - bl rfu_REQ_sendData_wrapper - b _0800F1CC - .pool -_0800F1C8: - bl rfu_REQ_PARENT_resumeRetransmitAndChange -_0800F1CC: - ldr r1, =gUnknown_03005000 - movs r0, 0x1 - strb r0, [r1, 0xE] -_0800F1D2: - movs r0, 0 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_800F0F8 - thumb_func_start sub_800F1E0 sub_800F1E0: @ 800F1E0 push {r4-r7,lr} diff --git a/include/librfu.h b/include/librfu.h index 29c1f94644..9e1c2ff600 100644 --- a/include/librfu.h +++ b/include/librfu.h @@ -221,3 +221,4 @@ bool16 rfu_UNI_setSendData(u8 flag, void *ptr, u8 size); void rfu_REQ_recvData(void); void rfu_UNI_readySendData(u8 a0); void rfu_UNI_clearRecvNewDataFlag(u8 a0); +void rfu_REQ_PARENT_resumeRetransmitAndChange(void); diff --git a/include/link_rfu.h b/include/link_rfu.h index f17becf103..278bb084c9 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -140,7 +140,8 @@ struct UnkRfuStruct_2 { /* 0x006 */ u8 filler_06[6]; /* 0x00c */ u8 unk_0c; /* 0x00d */ u8 playerCount; - /* 0x00e */ u8 filler_0e[6]; + /* 0x00e */ u8 unk_0e; + /* 0x00f */ u8 filler_0f[5]; /* 0x014 */ u8 unk_14[4][14]; /* 0x04c */ u8 unk_4c[14]; /* 0x05a */ u8 filler_5a[13]; @@ -166,7 +167,8 @@ struct UnkRfuStruct_2 { /* 0xcd1 */ u8 filler_cd1[9]; /* 0xcda */ u8 unk_cda; /* 0xcdb */ vu8 unk_cdb; - /* 0xcdc */ u8 filler_cdc[2]; + /* 0xcdc */ vu8 unk_cdc; + /* 0xcdd */ u8 unk_cdd; /* 0xcde */ u8 unk_cde[4]; /* 0xce2 */ u8 unk_ce2; /* 0xce2 */ u8 unk_ce3; diff --git a/src/link_rfu.c b/src/link_rfu.c index 7ac380ddf7..06fdbe207c 100644 --- a/src/link_rfu.c +++ b/src/link_rfu.c @@ -62,7 +62,9 @@ void sub_801084C(u8 taskId); void sub_8010AAC(u8 taskId); void sub_8010D0C(u8 taskId); void sub_8011068(u8 a0); -void sub_8011A64(u8 a0, u8 a1); +void sub_8011170(u32 a0); +void sub_8011A64(u8 a0, u16 a1); +void sub_8011D6C(u8 a0); u8 sub_8012224(void); void sub_801227C(void); @@ -2963,3 +2965,71 @@ static void sub_800F048(void) sub_800DA68(&gUnknown_03005000.unk_c1c, gUnknown_03005000.unk_4c); } } + +bool32 sub_800F0B8(void) +{ + int i; + int j; + + if (gUnknown_03007890->unk_06 == 0) + { + return FALSE; + } + for (i = 0; i < 5; i++) + { + for (j = 0; j < 7; j++) + { + if (gRecvCmds[i][j] != 0) + { + return FALSE; + } + } + } + return TRUE; +} + +bool32 sub_800F0F8(void) +{ + if (gUnknown_03005000.unk_04 < 20) + { + rfu_REQ_recvData(); + rfu_waitREQComplete(); + rfu_REQ_sendData_wrapper(0); + } + else + { + gUnknown_03005000.unk_cdb = 0; + if ((gUnknown_03005000.unk_ce2 & gUnknown_03007890->unk_02) == gUnknown_03005000.unk_ce2 && (gUnknown_03005000.unk_ce2 & gUnknown_03007890->unk_02)) + { + if (!gUnknown_03005000.unk_cdc) + { + if (gUnknown_03005000.unk_ce3) + { + sub_8011D6C(gUnknown_03005000.unk_ce3); + gUnknown_03005000.unk_ce3 = 0; + if (gUnknown_03005000.unk_ce4 == 1) + { + sub_8011A64(2, 0x8000); + sub_8011170(0x8000); + return FALSE; + } + if (!gUnknown_03004140.unk_00) + { + sub_800EDD4(); + gReceivedRemoteLinkPlayers = 0; + return FALSE; + } + } + sub_800EFB0(); + rfu_UNI_readySendData(gUnknown_03005000.unk_cda); + rfu_REQ_sendData_wrapper(1); + } + else + { + rfu_REQ_PARENT_resumeRetransmitAndChange(); + } + gUnknown_03005000.unk_0e = 1; + } + } + return FALSE; +}