From cd4aa5efe5e3ca9ad96ceee0462ff69c99d3fc92 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 4 Nov 2017 11:49:28 -0400 Subject: [PATCH] through sub_80E7820 --- asm/record_mixing.s | 109 -------------------------------------------- src/record_mixing.c | 71 +++++++++++++++++++++++++---- 2 files changed, 61 insertions(+), 119 deletions(-) diff --git a/asm/record_mixing.s b/asm/record_mixing.s index e3e818a7e2..50bc0037d8 100644 --- a/asm/record_mixing.s +++ b/asm/record_mixing.s @@ -5,115 +5,6 @@ .text - thumb_func_start sub_80E776C -sub_80E776C: @ 80E776C - push {r4,lr} - lsls r0, 24 - lsrs r3, r0, 24 - lsls r0, r3, 2 - adds r0, r3 - lsls r0, 3 - ldr r2, =gTasks - adds r0, r2 - movs r4, 0x1C - ldrsh r1, [r0, r4] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r2 - ldrb r0, [r0, 0x4] - cmp r0, 0 - bne _080E7794 - adds r0, r3, 0 - bl DestroyTask -_080E7794: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80E776C - - thumb_func_start sub_80E77A0 -sub_80E77A0: @ 80E77A0 - push {lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks - adds r1, r0 - ldr r0, =sub_80E776C - str r0, [r1] - ldr r0, =gUnknown_03001130 - ldrb r0, [r0] - cmp r0, 0x1 - bne _080E77C4 - movs r2, 0x12 - ldrsh r0, [r1, r2] - bl sub_80E6F60 -_080E77C4: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80E77A0 - - thumb_func_start sub_80E77D4 -sub_80E77D4: @ 80E77D4 - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - ldr r0, =sub_80E77A0 - str r0, [r1] - ldr r1, =gUnknown_03001130 - movs r0, 0x1 - strb r0, [r1] - bx lr - .pool - thumb_func_end sub_80E77D4 - - thumb_func_start sub_80E77FC -sub_80E77FC: @ 80E77FC - adds r1, r0, 0 - ldrh r0, [r1] - ldrh r1, [r1, 0x2] - lsls r1, 16 - orrs r0, r1 - bx lr - thumb_func_end sub_80E77FC - - thumb_func_start sub_80E7808 -sub_80E7808: @ 80E7808 - strh r0, [r1] - lsrs r0, 16 - strh r0, [r1, 0x2] - bx lr - thumb_func_end sub_80E7808 - - thumb_func_start sub_80E7810 -sub_80E7810: @ 80E7810 - push {lr} - bl GetMultiplayerId - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - thumb_func_end sub_80E7810 - - thumb_func_start sub_80E7820 -sub_80E7820: @ 80E7820 - lsls r0, 24 - lsrs r0, 16 - ldr r1, =gBlockRecvBuffer - adds r0, r1 - bx lr - .pool - thumb_func_end sub_80E7820 - thumb_func_start sub_80E7830 sub_80E7830: @ 80E7830 push {r4,lr} diff --git a/src/record_mixing.c b/src/record_mixing.c index d006342123..01b19cbb3d 100644 --- a/src/record_mixing.c +++ b/src/record_mixing.c @@ -68,11 +68,11 @@ static void sub_80E715C(u8 taskId); static void sub_80E7324(u8 taskId); static void sub_80E756C(u8 taskId); static void sub_80E7630(u8 taskId); -void sub_80E77D4(u8 taskId); -void *sub_80E77FC(s16 *asShort); -u8 sub_80E7810(void); -void *sub_80E7820(u8); -void sub_80E7808(struct PlayerRecords *records, s16 *a1); +static void sub_80E77D4(u8 taskId); +static void *sub_80E77FC(const u16 *asShort); +static void sub_80E7808(void *records, u16 *a1); +static u8 sub_80E7810(void); +static void *sub_80E7820(u8); void sub_80E78C4(OldMan *, size_t, u8); void sub_80E7948(void *, size_t, u8); void sub_80E7A14(LilycoveLady *, size_t, u8); @@ -378,20 +378,20 @@ static void sub_80E7324(u8 taskId) task->func = sub_80E756C; if (Link_AnyPartnersPlayingRubyOrSapphrie()) { - sub_80E7808(gUnknown_0203A018, &task->data[2]); + sub_80E7808(gUnknown_0203A018, (u16 *)&task->data[2]); taskId2 = CreateTask(sub_80E7630, 80); task->data[10] = taskId2; gTasks[taskId2].data[0] = taskId; - sub_80E7808(gUnknown_0203A014, &gTasks[taskId2].data[5]); + sub_80E7808(gUnknown_0203A014, (u16 *)&gTasks[taskId2].data[5]); gUnknown_0300115C = 0x1230; } else { - sub_80E7808(gUnknown_0203A018, &task->data[2]); + sub_80E7808(gUnknown_0203A018, (u16 *)&task->data[2]); taskId2 = CreateTask(sub_80E7630, 80); task->data[10] = taskId2; gTasks[taskId2].data[0] = taskId; - sub_80E7808(gUnknown_0203A014, &gTasks[taskId2].data[5]); + sub_80E7808(gUnknown_0203A014, (u16 *)&gTasks[taskId2].data[5]); gUnknown_0300115C = 0x1444; } break; @@ -465,7 +465,7 @@ static void sub_80E7630(u8 taskId) { if ((status >> i) & 0x01) { - dest = sub_80E77FC(&task->data[5]) + task->data[i + 1] * 200 + gUnknown_0300115C * i; + dest = sub_80E77FC((u16 *)&task->data[5]) + task->data[i + 1] * 200 + gUnknown_0300115C * i; src = sub_80E7820(i); if ((task->data[i + 1] + 1) * 200 > gUnknown_0300115C) { @@ -490,3 +490,54 @@ static void sub_80E7630(u8 taskId) DestroyTask(taskId); } } + +static void sub_80E776C(u8 taskId) +{ + struct Task *task; + + task = &gTasks[taskId]; + if (!gTasks[task->data[10]].isActive) + { + DestroyTask(taskId); + } +} + +static void sub_80E77A0(u8 taskId) +{ + struct Task *task; + + task = &gTasks[taskId]; + task->func = sub_80E776C; + if (gUnknown_03001130 == TRUE) + { + sub_80E6F60(task->data[5]); + } +} + +static void sub_80E77D4(u8 taskId) +{ + gTasks[taskId].func = sub_80E77A0; + gUnknown_03001130 = TRUE; +} + + +static void *sub_80E77FC(const u16 *asShort) +{ + return (void *)(asShort[0] | (asShort[1] << 16)); +} + +static void sub_80E7808(void *data, u16 *asShort) +{ + asShort[0] = (u32)data; + asShort[1] = ((u32)data >> 16); +} + +static u8 sub_80E7810(void) +{ + return GetMultiplayerId(); +} + +static void *sub_80E7820(u8 id) +{ + return gBlockRecvBuffer[id]; +}