diff --git a/asm/link_rfu.s b/asm/link_rfu.s index baddaf055..1a6091803 100644 --- a/asm/link_rfu.s +++ b/asm/link_rfu.s @@ -5,202 +5,6 @@ .text - thumb_func_start sub_800F6FC -sub_800F6FC: @ 800F6FC - push {lr} - lsls r0, 24 - lsrs r1, r0, 24 - ldr r0, =gUnknown_03005000 - ldrb r2, [r0, 0xC] - cmp r2, 0x1 - bne _0800F71C - cmp r1, 0 - beq _0800F71C - adds r0, 0x61 - adds r0, r1, r0 - strb r2, [r0] - b _0800F724 - .pool -_0800F71C: - adds r0, 0x5C - adds r0, r1, r0 - movs r1, 0x1 - strb r1, [r0] -_0800F724: - pop {r0} - bx r0 - thumb_func_end sub_800F6FC - - thumb_func_start sub_800F728 -sub_800F728: @ 800F728 - lsls r0, 24 - lsrs r0, 24 - ldr r3, =gUnknown_03005000 - adds r1, r3, 0 - adds r1, 0x5C - adds r1, r0, r1 - movs r2, 0 - strb r2, [r1] - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 2 - adds r1, r3 - adds r1, 0x92 - strb r2, [r1] - bx lr - .pool - thumb_func_end sub_800F728 - - thumb_func_start sub_800F74C -sub_800F74C: @ 800F74C - push {r4,r5,lr} - adds r3, r0, 0 - ldr r0, =gUnknown_03005000 - ldrb r1, [r0, 0xC] - adds r5, r0, 0 - cmp r1, 0x1 - bne _0800F764 - movs r0, 0 - b _0800F786 - .pool -_0800F764: - movs r2, 0 - ldr r0, =0x00000cde - adds r4, r5, r0 -_0800F76A: - adds r1, r2, r4 - adds r0, r3, r2 - ldrb r0, [r0] - strb r0, [r1] - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x3 - bls _0800F76A - ldr r1, =0x00000c3e - adds r0, r5, r1 - ldrb r0, [r0] - adds r0, r3 - ldrb r0, [r0] -_0800F786: - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_800F74C - - thumb_func_start rfu_func_080F97B8 -rfu_func_080F97B8: @ 800F794 - push {lr} - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - beq _0800F7C6 - ldr r3, =gUnknown_03005DA8 - ldrh r2, [r3] - cmp r2, 0 - beq _0800F7C6 - ldr r0, =gLinkTransferringData - ldrb r0, [r0] - cmp r0, 0x1 - beq _0800F7C6 - ldr r1, =gUnknown_03000D78 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - ldrb r0, [r1] - lsls r0, 8 - orrs r0, r2 - strh r0, [r3] - movs r0, 0xBE - lsls r0, 8 - bl sub_800FD14 -_0800F7C6: - pop {r0} - bx r0 - .pool - thumb_func_end rfu_func_080F97B8 - - thumb_func_start sub_800F7DC -sub_800F7DC: @ 800F7DC - ldr r0, =gUnknown_02022B14 - bx lr - .pool - thumb_func_end sub_800F7DC - - thumb_func_start sub_800F7E4 -sub_800F7E4: @ 800F7E4 - push {lr} - movs r2, 0 - ldr r0, =gUnknown_03005000 - ldr r1, [r0] - ldr r0, =rfu_func_080F97B8 - cmp r1, r0 - bne _0800F7F4 - movs r2, 0x1 -_0800F7F4: - adds r0, r2, 0 - pop {r1} - bx r1 - .pool - thumb_func_end sub_800F7E4 - - thumb_func_start sub_800F804 -sub_800F804: @ 800F804 - ldr r1, =gUnknown_03005000 - ldr r0, =rfu_func_080F97B8 - str r0, [r1] - bx lr - .pool - thumb_func_end sub_800F804 - - thumb_func_start Rfu_set_zero -Rfu_set_zero: @ 800F814 - ldr r1, =gUnknown_03005000 - movs r0, 0 - str r0, [r1] - bx lr - .pool - thumb_func_end Rfu_set_zero - - thumb_func_start sub_800F820 -sub_800F820: @ 800F820 - push {lr} - movs r0, 0x88 - lsls r0, 7 - bl sub_800FD14 - bl GetMultiplayerId - lsls r0, 24 - cmp r0, 0 - bne _0800F83C - bl GetBlenderArrowPosition - ldr r1, =gSendCmd - strh r0, [r1, 0xC] -_0800F83C: - ldr r1, =gUnknown_020223C0 - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end sub_800F820 - - thumb_func_start sub_800F850 -sub_800F850: @ 800F850 - push {lr} - ldr r1, =gUnknown_03005000 - ldr r0, [r1] - cmp r0, 0 - bne _0800F85E - ldr r0, =sub_800F820 - str r0, [r1] -_0800F85E: - pop {r0} - bx r0 - .pool - thumb_func_end sub_800F850 - thumb_func_start sub_800F86C sub_800F86C: @ 800F86C push {r4-r7,lr} diff --git a/include/link.h b/include/link.h index c01f24d27..918a7480b 100644 --- a/include/link.h +++ b/include/link.h @@ -195,6 +195,7 @@ extern struct LinkPlayer gLinkPlayers[5]; extern u16 word_3002910[]; extern bool8 gReceivedRemoteLinkPlayers; extern bool8 gWirelessCommType; +extern u32 gUnknown_020223C0; void Task_DestroySelf(u8); void OpenLink(void); diff --git a/include/link_rfu.h b/include/link_rfu.h index 6e8346a88..144a863b5 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -136,7 +136,7 @@ struct UnkRfuStruct_Sub_Unused { }; struct UnkRfuStruct_2 { - /* 0x000 */ u32 unk_00; + /* 0x000 */ void (*unk_00)(void); /* 0x004 */ u16 unk_04; /* 0x006 */ u8 filler_06[6]; /* 0x00c */ u8 unk_0c; @@ -145,7 +145,10 @@ struct UnkRfuStruct_2 { /* 0x00f */ u8 filler_0f[5]; /* 0x014 */ u8 unk_14[4][14]; /* 0x04c */ u8 unk_4c[14]; - /* 0x05a */ u8 filler_5a[13]; + /* 0x05a */ u8 filler_5a[2]; + /* 0x05c */ u8 unk_5c[5]; + /* 0x061 */ u8 unk_61[5]; + /* 0x066 */ u8 unk_66; /* 0x067 */ u8 unk_67; /* 0x068 */ u8 filler_68[4]; /* 0x06c */ struct UnkRfuStruct_2_Sub_6c unk_6c; diff --git a/src/link_rfu.c b/src/link_rfu.c index 10a6a7914..2fe991c41 100644 --- a/src/link_rfu.c +++ b/src/link_rfu.c @@ -2,12 +2,14 @@ // Includes #include "global.h" #include "malloc.h" +#include "berry_blender.h" #include "task.h" #include "random.h" #include "decompress.h" #include "text.h" #include "string_util.h" #include "event_data.h" +#include "overworld.h" #include "link.h" #include "librfu.h" #include "link_rfu.h" @@ -56,6 +58,7 @@ static void sub_800F048(void); struct UnkLinkRfuStruct_02022B14 *sub_800F7DC(void); void sub_800F86C(u8 a0); void sub_800FCC4(struct UnkRfuStruct_2_Sub_6c *data); +void sub_800FD14(u16 a0); bool32 sub_8010454(u16 a0); void sub_8010528(void); void sub_8010750(void); @@ -3316,3 +3319,74 @@ __attribute__((naked)) void sub_800F638(u8 unused, u32 flags) "\t.pool"); } #endif + +void sub_800F6FC(u8 a0) +{ + if (gUnknown_03005000.unk_0c == 1 && a0) + gUnknown_03005000.unk_61[a0] = 1; + else + gUnknown_03005000.unk_5c[a0] = 1; +} + +void sub_800F728(u8 a0) +{ + gUnknown_03005000.unk_5c[a0] = 0; + gUnknown_03005000.unk_80[a0].unk_12 = 0; +} + +u8 sub_800F74C(const u8 *a0) +{ + u8 i; + + if (gUnknown_03005000.unk_0c == 1) + return FALSE; + for (i = 0; i < 4; i++) + { + gUnknown_03005000.unk_cde[i] = a0[i]; + } + return a0[gUnknown_03005000.unk_c3e]; +} + +void rfu_func_080F97B8(void) +{ + if (gReceivedRemoteLinkPlayers && gUnknown_03005DA8 && gLinkTransferringData != 1) + { + gUnknown_03000D78[0]++; + gUnknown_03005DA8 |= (gUnknown_03000D78[0] << 8); + sub_800FD14(0xbe00); + } +} + +struct UnkLinkRfuStruct_02022B14 *sub_800F7DC(void) +{ + return &gUnknown_02022B14; +} + +bool32 sub_800F7E4(void) +{ + return gUnknown_03005000.unk_00 == rfu_func_080F97B8; +} + +void sub_800F804(void) +{ + gUnknown_03005000.unk_00 = rfu_func_080F97B8; +} + +void Rfu_set_zero(void) +{ + gUnknown_03005000.unk_00 = NULL; +} + +void sub_800F820(void) +{ + sub_800FD14(0x4400); + if (GetMultiplayerId() == 0) + gSendCmd[6] = GetBlenderArrowPosition(); + gUnknown_020223C0++; +} + +void sub_800F850(void) +{ + if (gUnknown_03005000.unk_00 == NULL) + gUnknown_03005000.unk_00 = sub_800F820; +}