diff --git a/asm/link_rfu.s b/asm/link_rfu.s index 64f564d08..d1eb8c9d2 100644 --- a/asm/link_rfu.s +++ b/asm/link_rfu.s @@ -5,70 +5,6 @@ .text - thumb_func_start sub_800CEB0 -sub_800CEB0: @ 800CEB0 - push {r4-r7,lr} - sub sp, 0x4 - lsls r0, 16 - lsrs r6, r0, 16 - ldr r4, =gUnknown_03004140 - ldrb r7, [r4, 0xE] - movs r0, 0 - strb r0, [r4, 0xE] - movs r0, 0x1 - strb r0, [r4, 0xF] - ldr r0, =gUnknown_03007890 - ldr r0, [r0] - ldrb r5, [r0] - cmp r5, 0 - bne _0800CEEC - adds r0, r6, 0 - bl sub_800C36C - ldrb r0, [r4, 0x2] - cmp r0, 0x1 - beq _0800CF04 - bl sub_800D610 - strb r5, [r4, 0xF] - strb r7, [r4, 0xE] - b _0800CF28 - .pool -_0800CEEC: - mov r0, sp - bl rfu_UNI_PARENT_getDRAC_ACK - lsls r0, 16 - cmp r0, 0 - bne _0800CF04 - mov r1, sp - ldrb r0, [r4, 0x3] - ldrb r1, [r1] - orrs r0, r1 - ldrb r1, [r4, 0x3] - strb r0, [r4, 0x3] -_0800CF04: - ldr r4, =gUnknown_03004140 - ldr r1, [r4, 0x44] - cmp r1, 0 - beq _0800CF20 - adds r0, r6, 0 - bl _call_via_r1 - bl rfu_waitREQComplete - ldrb r0, [r4, 0x2] - cmp r0, 0x2 - bne _0800CF20 - bl sub_800D610 -_0800CF20: - ldr r1, =gUnknown_03004140 - movs r0, 0 - strb r0, [r1, 0xF] - strb r7, [r1, 0xE] -_0800CF28: - add sp, 0x4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_800CEB0 - thumb_func_start sub_800CF34 sub_800CF34: @ 800CF34 push {r4-r7,lr} diff --git a/include/librfu.h b/include/librfu.h index 65e981dda..7891f8679 100644 --- a/include/librfu.h +++ b/include/librfu.h @@ -183,3 +183,4 @@ u8 rfu_NI_CHILD_setSendGameName(u8 a0, u8 a1); void rfu_clearSlot(u8 a0, u8 a1); bool16 rfu_CHILD_getConnectRecoveryStatus(u8 *status); bool16 rfu_getConnectParentStatus(u8 *status, u8 *a1); +bool16 rfu_UNI_PARENT_getDRAC_ACK(u8 *a0); diff --git a/include/link_rfu.h b/include/link_rfu.h index 69c7d2e2b..8634a4706 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -74,7 +74,7 @@ struct UnkRfuStruct_1 { /* 0x034 */ u16 unk_34[4]; /* 0x03c */ struct UnkLinkRfuStruct_02022B2C *unk_3c; /* 0x040 */ void (*unk_40)(u8); - /* 0x044 */ void (*unk_44)(void); + /* 0x044 */ void (*unk_44)(u16); /* 0x048 */ u8 filler_48[0xe78]; }; diff --git a/src/link_rfu.c b/src/link_rfu.c index 12ec3e708..5beb7c88b 100644 --- a/src/link_rfu.c +++ b/src/link_rfu.c @@ -84,7 +84,7 @@ void rfu_REQ_sendData_wrapper(u8 r2) rfu_REQ_sendData(r2); } -int sub_800BF4C(void (*func1)(u8), void (*func2)(void)) +int sub_800BF4C(void (*func1)(u8), void (*func2)(u16)) { if (func1 == NULL) { @@ -976,3 +976,42 @@ void sub_800C7B4(u16 r8, u16 r6) sub_800D610(); } } + +void sub_800CEB0(u16 r6) +{ + u8 r7; + u8 sp0; + + r7 = gUnknown_03004140.unk_0e; + gUnknown_03004140.unk_0e = 0; + gUnknown_03004140.unk_0f = 1; + if (gUnknown_03007890->unk_00 == 0) + { + sub_800C36C(r6); + if (gUnknown_03004140.unk_02 != 1) + { + sub_800D610(); + gUnknown_03004140.unk_0f = 0; + gUnknown_03004140.unk_0e = r7; + return; + } + } + else + { + if (!rfu_UNI_PARENT_getDRAC_ACK(&sp0)) + { + gUnknown_03004140.unk_03 |= sp0; + } + } + if (gUnknown_03004140.unk_44 != NULL) + { + gUnknown_03004140.unk_44(r6); + rfu_waitREQComplete(); + if (gUnknown_03004140.unk_02 == 2) + { + sub_800D610(); + } + } + gUnknown_03004140.unk_0f = 0; + gUnknown_03004140.unk_0e = r7; +}