diff --git a/asm/link_rfu.s b/asm/link_rfu.s index adc7e7d82..47e3526e7 100644 --- a/asm/link_rfu.s +++ b/asm/link_rfu.s @@ -5,136 +5,6 @@ .text - thumb_func_start sub_800D434 -sub_800D434: @ 800D434 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - ldr r0, =gUnknown_03004140 - ldrh r0, [r0, 0x18] - cmp r0, 0 - beq _0800D510 - ldr r0, =gUnknown_03007890 - ldr r0, [r0] - ldrb r0, [r0, 0x4] - cmp r0, 0 - beq _0800D4D4 - movs r6, 0 -_0800D454: - ldr r3, =gUnknown_03007880 - lsls r2, r6, 2 - adds r0, r2, r3 - ldr r0, [r0] - ldrh r1, [r0] - movs r4, 0x80 - lsls r4, 8 - adds r0, r4, 0 - ands r1, r0 - adds r7, r2, 0 - adds r0, r6, 0x1 - mov r9, r0 - cmp r1, 0 - beq _0800D4CA - movs r5, 0 - movs r4, 0 - movs r1, 0x1 - mov r8, r1 - mov r10, r3 -_0800D47A: - adds r0, r7, r3 - ldr r0, [r0] - ldrb r0, [r0, 0x1A] - asrs r0, r4 - mov r1, r8 - ands r0, r1 - cmp r0, 0 - beq _0800D4A4 - lsls r0, r4, 2 - adds r0, r3 - ldr r0, [r0] - ldr r1, =gUnknown_03004140 - ldrh r0, [r0, 0x2] - ldrh r1, [r1, 0x18] - cmp r0, r1 - bls _0800D4A4 - mov r0, r8 - lsls r0, r4 - orrs r5, r0 - lsls r0, r5, 24 - lsrs r5, r0, 24 -_0800D4A4: - cmp r5, 0 - beq _0800D4C0 - mov r1, r10 - adds r0, r7, r1 - ldr r0, [r0] - ldrb r0, [r0, 0x1A] - adds r2, r5, 0 - eors r2, r0 - movs r0, 0x20 - adds r1, r6, 0 - str r3, [sp] - bl rfu_changeSendTarget - ldr r3, [sp] -_0800D4C0: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x3 - bls _0800D47A -_0800D4CA: - mov r3, r9 - lsls r0, r3, 24 - lsrs r6, r0, 24 - cmp r6, 0x3 - bls _0800D454 -_0800D4D4: - ldr r0, =gUnknown_03007890 - ldr r0, [r0] - ldrb r0, [r0, 0x5] - cmp r0, 0 - beq _0800D510 - movs r6, 0 -_0800D4E0: - ldr r1, =gUnknown_03007880 - lsls r0, r6, 2 - adds r0, r1 - ldr r2, [r0] - ldrh r0, [r2, 0x34] - movs r4, 0x80 - lsls r4, 8 - adds r1, r4, 0 - ands r0, r1 - cmp r0, 0 - beq _0800D506 - ldr r1, =gUnknown_03004140 - ldrh r0, [r2, 0x36] - ldrh r1, [r1, 0x18] - cmp r0, r1 - bls _0800D506 - adds r0, r6, 0 - bl rfu_NI_stopReceivingData -_0800D506: - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0x3 - bls _0800D4E0 -_0800D510: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_800D434 - thumb_func_start sub_800D52C sub_800D52C: @ 800D52C push {lr} diff --git a/include/librfu.h b/include/librfu.h index 8d61c2559..90bae1dbb 100644 --- a/include/librfu.h +++ b/include/librfu.h @@ -117,11 +117,13 @@ struct RfuUnk1 struct RfuUnk2 { u16 unk_0; - u8 fill_2[0x18]; + u16 unk_2; + u8 fill_4[0x16]; u8 unk_1a; u8 fill_1b[0x19]; u16 unk_34; - u8 fill_36[0x18]; + u16 unk_36; + u8 fill_38[0x16]; u8 unk_4e; u8 fill_4f[0x12]; u8 unk_61; diff --git a/src/link_rfu.c b/src/link_rfu.c index ffe119a17..e47a42bb4 100644 --- a/src/link_rfu.c +++ b/src/link_rfu.c @@ -35,7 +35,7 @@ static u8 sub_800D294(void); void sub_800D30C(u8 a0, u8 a1); static void sub_800D334(u8 a0); static void sub_800D358(u8 a0); -void sub_800D434(void); +static void sub_800D434(void); void sub_800D610(void); void sub_800D630(void); @@ -1263,3 +1263,45 @@ static void sub_800D358(u8 a0) } } } + +static void sub_800D434(void) +{ + u8 i; + u8 j; + u8 flags; + + if (gUnknown_03004140.unk_18) + { + if (gUnknown_03007890->unk_04) + { + for (i = 0; i < 4; i ++) + { + if (gUnknown_03007880[i]->unk_0 & 0x8000) + { + flags = 0; + for (j = 0; j < 4; j++) + { + if ((gUnknown_03007880[i]->unk_1a >> j) & 1 && gUnknown_03007880[j]->unk_2 > gUnknown_03004140.unk_18) + { + flags |= (1 << j); + } + if (flags) + { + rfu_changeSendTarget(0x20, i, flags ^ gUnknown_03007880[i]->unk_1a); + } + } + } + } + } + if (gUnknown_03007890->unk_05) + { + for (i = 0; i < 4; i++) + { + if (gUnknown_03007880[i]->unk_34 & 0x8000 && gUnknown_03007880[i]->unk_36 > gUnknown_03004140.unk_18) + { + rfu_NI_stopReceivingData(i); + } + } + } + } +}