diff --git a/asm/link.s b/asm/link.s index ff0bfb3c9..828e9f8b3 100644 --- a/asm/link.s +++ b/asm/link.s @@ -5,69 +5,6 @@ .text - thumb_func_start sub_800A2E0 -sub_800A2E0: @ 800A2E0 - ldr r1, =gUnknown_03000D10 - movs r0, 0 - strb r0, [r1, 0x8] - strh r0, [r1] - strh r0, [r1, 0x2] - str r0, [r1, 0x4] - bx lr - .pool - thumb_func_end sub_800A2E0 - - thumb_func_start sub_800A2F4 -sub_800A2F4: @ 800A2F4 - push {r4-r7,lr} - adds r7, r0, 0 - adds r6, r1, 0 - ldr r4, =gUnknown_03000D10 - ldrb r5, [r4, 0x8] - cmp r5, 0 - beq _0800A30C - movs r0, 0 - b _0800A34A - .pool -_0800A30C: - bl GetMultiplayerId - strb r0, [r4, 0x9] - movs r0, 0x1 - strb r0, [r4, 0x8] - strh r6, [r4, 0x2] - strh r5, [r4] - adds r0, 0xFF - cmp r6, r0 - bls _0800A324 - str r7, [r4, 0x4] - b _0800A336 -_0800A324: - ldr r5, =gUnknown_020228C4 - cmp r7, r5 - beq _0800A334 - adds r0, r5, 0 - adds r1, r7, 0 - adds r2, r6, 0 - bl memcpy -_0800A334: - str r5, [r4, 0x4] -_0800A336: - ldr r0, =0x0000bbbb - bl sub_8009D90 - ldr r1, =gUnknown_03003140 - ldr r0, =sub_800A364 - str r0, [r1] - ldr r1, =gUnknown_03000D50 - movs r0, 0 - str r0, [r1] - movs r0, 0x1 -_0800A34A: - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_800A2F4 - thumb_func_start sub_800A364 sub_800A364: @ 800A364 push {lr} diff --git a/src/link.c b/src/link.c index 3cb485b49..9fd243052 100644 --- a/src/link.c +++ b/src/link.c @@ -22,7 +22,7 @@ struct BlockTransfer { u16 pos; u16 size; - void *src; + const void *src; bool8 active; u8 multiplayerId; }; @@ -111,9 +111,10 @@ void sub_8009638(void); void sub_80096BC(void); static void c2_08009A8C(void); static void sub_8009AA0(u8 unused); -void sub_8009F70(void); -void sub_800A2E0(void); -void sub_800A2F4(void *heapptr, size_t src); +static void sub_8009F70(void); +static void sub_800A2E0(void); +bool32 sub_800A2F4(const void *src, size_t size); +void sub_800A364(void); void sub_800A418(void); void task00_link_test(u8 taskId); void sub_800A588(u8 who); @@ -671,7 +672,7 @@ bool32 sub_8009F3C(void) return FALSE; } -void sub_8009F70(void) +static void sub_8009F70(void) { if (gReceivedRemoteLinkPlayers == TRUE) { @@ -884,3 +885,39 @@ void sub_800A2BC(void) gLinkPlayers[i] = (struct LinkPlayer){}; } } + +static void sub_800A2E0(void) +{ + gUnknown_03000D10.active = FALSE; + gUnknown_03000D10.pos = 0; + gUnknown_03000D10.size = 0; + gUnknown_03000D10.src = NULL; +} + +bool32 sub_800A2F4(const void *src, size_t size) +{ + if (gUnknown_03000D10.active) + { + return FALSE; + } + gUnknown_03000D10.multiplayerId = GetMultiplayerId(); + gUnknown_03000D10.active = TRUE; + gUnknown_03000D10.size = size; + gUnknown_03000D10.pos = 0; + if (size > 0x100) + { + gUnknown_03000D10.src = src; + } + else + { + if (src != gUnknown_020228C4) + { + memcpy(gUnknown_020228C4, src, size); + } + gUnknown_03000D10.src = gUnknown_020228C4; + } + sub_8009D90(0xbbbb); + gUnknown_03003140 = sub_800A364; + gUnknown_03000D50 = 0; + return TRUE; +}