From a8e8bfb4c8868d3dd8cf0c5ead8af81acd8a17f0 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 20 Jan 2018 15:50:45 -0500 Subject: [PATCH] through sub_8010750 --- asm/link_rfu.s | 300 --------------------------------------------- include/librfu.h | 1 + include/link_rfu.h | 6 +- src/link_rfu.c | 123 +++++++++++++++++-- 4 files changed, 120 insertions(+), 310 deletions(-) diff --git a/asm/link_rfu.s b/asm/link_rfu.s index 1a964417b9..ff5553ce28 100644 --- a/asm/link_rfu.s +++ b/asm/link_rfu.s @@ -5,306 +5,6 @@ .text - thumb_func_start sub_8010540 -sub_8010540: @ 8010540 - push {r4-r7,lr} - mov r7, r8 - push {r7} - movs r7, 0 - movs r5, 0 - ldr r6, =gUnknown_03005000 - ldr r0, =0x00000c3e - adds r0, r6 - mov r8, r0 -_08010552: - ldr r1, =0x00000cd1 - adds r0, r6, r1 - adds r4, r5, r0 - ldrb r0, [r4] - subs r0, 0x5 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bls _080105DA - ldr r1, =gUnknown_03007880 - lsls r0, r5, 2 - adds r0, r1 - ldr r0, [r0] - ldrh r0, [r0, 0x34] - cmp r0, 0x46 - beq _08010576 - cmp r0, 0x48 - bne _080105C0 -_08010576: - ldr r2, =0x00000cd5 - adds r0, r6, r2 - adds r1, r5, r0 - ldrb r0, [r1] - cmp r0, 0x8 - bne _080105DA - movs r0, 0x9 - strb r0, [r4] - movs r0, 0xA - strb r0, [r1] - lsls r1, r5, 24 - lsrs r1, 24 - movs r0, 0x8 - bl rfu_clearSlot - movs r0, 0x80 - lsls r0, 17 - lsls r0, r5 - lsrs r0, 24 - movs r1, 0x8 - adds r2, r4, 0 - movs r3, 0x1 - bl rfu_NI_setSendData - movs r7, 0x1 - b _080105DA - .pool -_080105C0: - mov r2, r8 - ldrb r0, [r2] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - ldrh r0, [r0, 0x34] - cmp r0, 0x47 - bne _080105DA - lsls r1, r5, 24 - lsrs r1, 24 - movs r0, 0x8 - bl rfu_clearSlot -_080105DA: - adds r5, 0x1 - cmp r5, 0x3 - ble _08010552 - adds r0, r7, 0 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_8010540 - - thumb_func_start sub_80105EC -sub_80105EC: @ 80105EC - push {r4-r6,lr} - movs r3, 0 - movs r1, 0 - ldr r5, =gUnknown_03005000+0xCD5 - movs r6, 0x1 - movs r4, 0 -_080105F8: - adds r2, r1, r5 - ldrb r0, [r2] - cmp r0, 0xB - bne _0801060C - adds r0, r6, 0 - lsls r0, r1 - orrs r3, r0 - lsls r0, r3, 24 - lsrs r3, r0, 24 - strb r4, [r2] -_0801060C: - adds r1, 0x1 - cmp r1, 0x3 - ble _080105F8 - cmp r3, 0 - beq _08010620 - adds r0, r3, 0 - bl rfu_REQ_disconnect - bl rfu_waitREQComplete -_08010620: - movs r1, 0 - ldr r2, =gUnknown_03005000+0xCD5 -_08010624: - adds r0, r1, r2 - ldrb r0, [r0] - subs r0, 0xA - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bhi _0801063C - movs r0, 0x1 - b _08010644 - .pool -_0801063C: - adds r1, 0x1 - cmp r1, 0x3 - ble _08010624 - movs r0, 0 -_08010644: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_80105EC - - thumb_func_start sub_801064C -sub_801064C: @ 801064C - push {lr} - adds r2, r0, 0 - adds r0, r1, 0 - lsls r2, 16 - lsrs r2, 16 - adds r1, r2, 0 - bl sub_8011CE4 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0xFF - beq _08010680 - ldr r0, =gUnknown_03005000 - ldr r2, =0x00000cd1 - adds r0, r2 - adds r0, r1, r0 - ldrb r0, [r0] - cmp r0, 0x9 - beq _08010680 - movs r0, 0 - b _08010682 - .pool -_08010680: - movs r0, 0x1 -_08010682: - pop {r1} - bx r1 - thumb_func_end sub_801064C - - thumb_func_start sub_8010688 -sub_8010688: @ 8010688 - push {r4-r6,lr} - adds r6, r0, 0 - adds r0, r2, 0 - lsls r6, 24 - lsrs r6, 24 - lsls r1, 16 - lsrs r1, 16 - bl sub_8011CE4 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r5, =gUnknown_03005000 - ldr r0, =0x00000cd1 - adds r5, r0 - adds r5, r4, r5 - strb r6, [r5] - movs r0, 0x4 - adds r1, r4, 0 - bl rfu_clearSlot - movs r0, 0x80 - lsls r0, 17 - lsls r0, r4 - lsrs r0, 24 - movs r1, 0x8 - adds r2, r5, 0 - movs r3, 0x1 - bl rfu_NI_setSendData - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8010688 - - thumb_func_start sub_80106D4 -sub_80106D4: @ 80106D4 - push {r4,r5,lr} - ldr r4, =gUnknown_03005000 - ldr r0, =0x00000c85 - adds r5, r4, r0 - movs r0, 0x8 - strb r0, [r5] - ldr r0, =0x00000c3e - adds r4, r0 - ldrb r1, [r4] - movs r0, 0x4 - bl rfu_clearSlot - ldrb r1, [r4] - movs r0, 0x80 - lsls r0, 17 - lsls r0, r1 - lsrs r0, 24 - movs r1, 0x8 - adds r2, r5, 0 - movs r3, 0x1 - bl rfu_NI_setSendData - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80106D4 - - thumb_func_start sub_8010714 -sub_8010714: @ 8010714 - push {lr} - adds r2, r0, 0 - adds r0, r1, 0 - lsls r2, 16 - lsrs r2, 16 - adds r1, r2, 0 - bl sub_8011CE4 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0xFF - bne _08010730 - movs r0, 0x2 - b _0801074A -_08010730: - ldr r1, =gUnknown_03007880 - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - ldrh r0, [r0] - cmp r0, 0 - beq _08010748 - movs r0, 0 - b _0801074A - .pool -_08010748: - movs r0, 0x1 -_0801074A: - pop {r1} - bx r1 - thumb_func_end sub_8010714 - - thumb_func_start sub_8010750 -sub_8010750: @ 8010750 - push {r4,r5,lr} - bl sub_8010540 - movs r4, 0 - ldr r0, =gUnknown_03005000 - ldr r1, =0x00000cd5 - adds r5, r0, r1 -_0801075E: - ldr r1, =gUnknown_03007880 - lsls r0, r4, 2 - adds r0, r1 - ldr r0, [r0] - ldrh r0, [r0] - subs r0, 0x26 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x1 - bhi _08010788 - adds r1, r4, r5 - ldrb r0, [r1] - cmp r0, 0xA - bne _0801077E - movs r0, 0xB - strb r0, [r1] -_0801077E: - lsls r1, r4, 24 - lsrs r1, 24 - movs r0, 0x4 - bl rfu_clearSlot -_08010788: - adds r4, 0x1 - cmp r4, 0x3 - ble _0801075E - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8010750 - thumb_func_start sub_80107A0 sub_80107A0: @ 80107A0 push {r4,r5,lr} diff --git a/include/librfu.h b/include/librfu.h index 88cbe2d3d6..9dd547eeec 100644 --- a/include/librfu.h +++ b/include/librfu.h @@ -223,3 +223,4 @@ void rfu_REQ_recvData(void); void rfu_UNI_readySendData(u8 a0); void rfu_UNI_clearRecvNewDataFlag(u8 a0); void rfu_REQ_PARENT_resumeRetransmitAndChange(void); +void rfu_NI_setSendData(u8, u8, u8 *, u8); diff --git a/include/link_rfu.h b/include/link_rfu.h index 7a79b8008d..b14a889bc9 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -176,13 +176,15 @@ struct UnkRfuStruct_2 { /* 0xc3d */ u8 unk_c3d; /* 0xc3e */ vu8 unk_c3e; /* 0xc3f */ u8 unk_c3f[70]; - /* 0xc85 */ u8 filler_c85[2]; + /* 0xc85 */ u8 unk_c85; + /* 0xc86 */ u8 unk_c86; /* 0xc87 */ u8 unk_c87[5][7][2]; /* 0xccd */ u8 unk_ccd; /* 0xcce */ u8 unk_cce; /* 0xccf */ u8 unk_ccf; /* 0xcd0 */ vu8 unk_cd0; - /* 0xcd1 */ u8 filler_cd1[8]; + /* 0xcd1 */ u8 unk_cd1[4]; + /* 0xcd5 */ u8 unk_cd5[4]; /* 0xcd9 */ u8 unk_cd9; /* 0xcda */ u8 unk_cda; /* 0xcdb */ vu8 unk_cdb; diff --git a/src/link_rfu.c b/src/link_rfu.c index aa5e114dae..0842818b48 100644 --- a/src/link_rfu.c +++ b/src/link_rfu.c @@ -59,11 +59,11 @@ static void sub_800F048(void); static void sub_800F86C(u8 unused); static void sub_800FCC4(struct UnkRfuStruct_2_Sub_6c *data); void sub_800FD14(u16 command); -void rfufunc_80F9F44(void); -void sub_800FFB0(void); -void rfufunc_80FA020(void); +static void rfufunc_80F9F44(void); +static void sub_800FFB0(void); +static void rfufunc_80FA020(void); bool32 sub_8010454(u32 a0); -void sub_8010528(void); +static void sub_8010528(void); void sub_8010750(void); int sub_80107A0(void); void sub_801084C(u8 taskId); @@ -71,6 +71,7 @@ void sub_80109E8(u16 a0); void sub_8010A70(void *a0); void sub_8010AAC(u8 taskId); void sub_8010D0C(u8 taskId); +u8 sub_8011CE4(const u8 *a0, u16 a1); void sub_8011D6C(u8 a0); u8 sub_8012224(void); void sub_801227C(void); @@ -3790,7 +3791,7 @@ bool32 sub_800FE84(const u8 *src, size_t size) return TRUE; } -void rfufunc_80F9F44(void) +static void rfufunc_80F9F44(void) { if (gSendCmd[0] == 0) { @@ -3808,7 +3809,7 @@ void rfufunc_80F9F44(void) } } -void sub_800FFB0(void) +static void sub_800FFB0(void) { int i; const u8 *src = gUnknown_03005000.unk_6c.unk_04; @@ -3823,7 +3824,7 @@ void sub_800FFB0(void) } } -void rfufunc_80FA020(void) +static void rfufunc_80FA020(void) { const u8 *src = gUnknown_03005000.unk_6c.unk_04; u8 mpId = GetMultiplayerId(); @@ -4062,8 +4063,114 @@ bool8 sub_8010500(void) return gUnknown_03005000.unk_00 ? FALSE : TRUE; } -void sub_8010528(void) +static void sub_8010528(void) { if (gUnknown_03005000.unk_00) gUnknown_03005000.unk_00(); } + +bool8 sub_8010540(void) +{ + int i; + bool8 retval = FALSE; + for (i = 0; i < 4; i++) + { + if (gUnknown_03005000.unk_cd1[i] < 5 || gUnknown_03005000.unk_cd1[i] > 6) + { + if (gUnknown_03007880[i]->unk_34 == 0x46 || gUnknown_03007880[i]->unk_34 == 0x48) + { + if (gUnknown_03005000.unk_cd5[i] == 8) + { + gUnknown_03005000.unk_cd1[i] = 9; + gUnknown_03005000.unk_cd5[i] = 10; + rfu_clearSlot(8, i); + rfu_NI_setSendData(1 << i, 8, gUnknown_03005000.unk_cd1 + i, 1); + retval = TRUE; + } + + } + else if (gUnknown_03007880[gUnknown_03005000.unk_c3e]->unk_34 == 0x47) + rfu_clearSlot(8, i); + { + + } + } + } + return retval; +} + +bool8 sub_80105EC(void) +{ + u8 flags = 0; + int i; + for (i = 0; i < 4; i++) + { + if (gUnknown_03005000.unk_cd5[i] == 11) + { + flags |= (1 << i); + gUnknown_03005000.unk_cd5[i] = 0; + } + } + if (flags) + { + rfu_REQ_disconnect(flags); + rfu_waitREQComplete(); + } + for (i = 0; i < 4; i++) + { + if (gUnknown_03005000.unk_cd5[i] == 10 || gUnknown_03005000.unk_cd5[i] == 11) + return TRUE; + } + return FALSE; +} + +bool8 sub_801064C(u16 a0, const u8 *a1) +{ + u8 r1 = sub_8011CE4(a1, a0); + if (r1 == 0xFF) + return TRUE; + if (gUnknown_03005000.unk_cd1[r1] == 9) + return TRUE; + return FALSE; +} + +void sub_8010688(u8 a0, u16 a1, const u8 *a2) +{ + u8 r4 = sub_8011CE4(a2, a1); + gUnknown_03005000.unk_cd1[r4] = a0; + rfu_clearSlot(4, r4); + rfu_NI_setSendData(1 << r4, 8, gUnknown_03005000.unk_cd1 + r4, 1); +} + +void sub_80106D4(void) +{ + gUnknown_03005000.unk_c85 = 8; + rfu_clearSlot(4, gUnknown_03005000.unk_c3e); + rfu_NI_setSendData(1 << gUnknown_03005000.unk_c3e, 8, &gUnknown_03005000.unk_c85, 1); +} + +u8 sub_8010714(u16 a0, const u8 *a1) +{ + u8 r0 = sub_8011CE4(a1, a0); + if (r0 == 0xff) + return 2; + if (gUnknown_03007880[r0]->unk_0 == 0) + return TRUE; + return FALSE; +} + +void sub_8010750(void) +{ + int i; + + sub_8010540(); + for (i = 0; i < 4; i++) + { + if (gUnknown_03007880[i]->unk_0 == 0x26 || gUnknown_03007880[i]->unk_0 == 0x27) + { + if (gUnknown_03005000.unk_cd5[i] == 10) + gUnknown_03005000.unk_cd5[i] = 11; + rfu_clearSlot(4, i); + } + } +}