From 44f7d49c2e6ee4cb58567c2566e48b859a3e3082 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 27 Mar 2019 09:54:19 -0400 Subject: [PATCH] Finish sub_8016CA0 --- asm/union_room.s | 169 ----------------------------------------------- src/union_room.c | 37 ++++++----- 2 files changed, 22 insertions(+), 184 deletions(-) diff --git a/asm/union_room.s b/asm/union_room.s index 576a1a51f..8e4cf9e1d 100755 --- a/asm/union_room.s +++ b/asm/union_room.s @@ -5,175 +5,6 @@ .text - thumb_func_start sub_8016CA0 -sub_8016CA0: @ 8016CA0 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x20 - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 - lsls r0, 2 - add r0, r10 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r6, r0, r1 - movs r7, 0 - mov r0, sp - adds r0, 0x10 - str r0, [sp, 0x18] -_08016CC4: - lsls r2, r7, 24 - lsrs r2, 24 - mov r0, sp - ldr r1, [sp, 0x18] - bl sub_800DE7C - lsls r0, 24 - lsrs r4, r0, 24 - mov r0, sp - ldrb r0, [r0, 0xA] - lsls r0, 25 - lsrs r0, 25 - mov r2, r10 - lsls r1, r2, 2 - add r1, r10 - lsls r1, 3 - ldr r3, =gTasks - adds r1, r3 - movs r5, 0x10 - ldrsh r1, [r1, r5] - bl sub_8013D88 - cmp r0, 0 - bne _08016D00 - mov r1, sp - ldr r0, =gUnknown_082F045C - ldm r0!, {r2,r3,r5} - stm r1!, {r2,r3,r5} - ldm r0!, {r2,r3,r5} - stm r1!, {r2,r3,r5} -_08016D00: - mov r0, sp - ldrb r1, [r0] - movs r0, 0xF - ands r0, r1 - cmp r0, 0x1 - bne _08016D18 - mov r1, sp - ldr r0, =gUnknown_082F045C - ldm r0!, {r2,r3,r5} - stm r1!, {r2,r3,r5} - ldm r0!, {r2,r3,r5} - stm r1!, {r2,r3,r5} -_08016D18: - cmp r4, 0 - bne _08016D9C - lsls r0, r7, 3 - mov r8, r0 - adds r1, r7, 0x1 - mov r9, r1 - cmp r7, 0 - ble _08016D58 - movs r2, 0 - str r2, [sp, 0x1C] - adds r4, r7, 0 -_08016D2E: - ldr r0, [r6, 0x4] - ldr r3, [sp, 0x1C] - adds r0, r3 - mov r1, sp - bl sub_8017630 - lsls r0, 24 - cmp r0, 0 - bne _08016D4C - mov r1, sp - ldr r0, =gUnknown_082F045C - ldm r0!, {r2,r3,r5} - stm r1!, {r2,r3,r5} - ldm r0!, {r2,r3,r5} - stm r1!, {r2,r3,r5} -_08016D4C: - ldr r5, [sp, 0x1C] - adds r5, 0x1C - str r5, [sp, 0x1C] - subs r4, 0x1 - cmp r4, 0 - bne _08016D2E -_08016D58: - ldr r1, [r6, 0x4] - mov r0, r8 - subs r4, r0, r7 - lsls r4, 2 - adds r1, r4 - mov r0, sp - ldm r0!, {r2,r3,r5} - stm r1!, {r2,r3,r5} - ldm r0!, {r2,r3,r5} - stm r1!, {r2,r3,r5} - ldr r0, [r6, 0x4] - adds r0, r4 - ldr r1, =gUnknown_082F045C - bl sub_8017630 - ldr r3, [r6, 0x4] - adds r3, r4 - movs r2, 0x1 - ands r2, r0 - ldrb r0, [r3, 0x18] - movs r4, 0x2 - negs r4, r4 - adds r1, r4, 0 - ands r0, r1 - orrs r0, r2 - strb r0, [r3, 0x18] - b _08016DD4 - .pool -_08016D9C: - ldr r1, [r6] - lsls r4, r7, 3 - subs r4, r7 - lsls r4, 2 - adds r1, r4 - mov r0, sp - ldm r0!, {r2,r3,r5} - stm r1!, {r2,r3,r5} - ldm r0!, {r2,r3,r5} - stm r1!, {r2,r3,r5} - ldr r0, [r6] - adds r0, r4 - ldr r1, =gUnknown_082F045C - bl sub_8017630 - ldr r3, [r6] - adds r3, r4 - movs r2, 0x1 - ands r2, r0 - ldrb r0, [r3, 0x18] - movs r4, 0x2 - negs r4, r4 - adds r1, r4, 0 - ands r0, r1 - orrs r0, r2 - strb r0, [r3, 0x18] - adds r7, 0x1 - mov r9, r7 -_08016DD4: - mov r7, r9 - cmp r7, 0x3 - bgt _08016DDC - b _08016CC4 -_08016DDC: - add sp, 0x20 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8016CA0 - thumb_func_start sub_8016DF0 sub_8016DF0: @ 8016DF0 push {r4-r6,lr} diff --git a/src/union_room.c b/src/union_room.c index 99ae4b679..b5c0bab80 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -46,7 +46,7 @@ struct UnkStruct_Shared struct UnkStruct_x1C { struct UnkStruct_Shared unk0; - u8 unk18; + u8 unk18:1; }; struct UnkStruct_x20 @@ -3468,33 +3468,40 @@ u8 sub_8016B00(void) return r7; } -/* void sub_8016CA0(u8 taskId) { s32 i, j; - struct UnkLinkRfuStruct_02022B14 sp0; - u8 text[10]; - struct UnkStruct_Main4 *ptr = (void*) gTasks[taskId].data; + struct UnkStruct_Shared sp0; + struct UnkStruct_Main4 **ptr = (void*) gTasks[taskId].data; + bool8 r4; for (i = 0; i < 4; i++) { - j = sub_800DE7C(&sp0, text, i); - if (!sub_8013D88(sp0.unk_0a_0, gTasks[taskId].data[4])) - sp0 = gUnknown_082F045C.field_0; - if (sp0.unk_00.unk_00_0 == 1) - sp0 = gUnknown_082F045C.field_0; - - if (!j) + r4 = sub_800DE7C(&sp0.field_0, sp0.playerName, i); + if (!sub_8013D88(sp0.field_0.unk_0a_0, gTasks[taskId].data[4])) + { + sp0 = gUnknown_082F045C; + } + if (sp0.field_0.unk_00.unk_00_0 == 1) + { + sp0 = gUnknown_082F045C; + } + if (!r4) { for (j = 0; j < i; j++) { - if (sub_8017630()) + if (!sub_8017630(&ptr[1]->arr[j].unk0, &sp0)) + { + sp0 = gUnknown_082F045C; + } } + ptr[1]->arr[i].unk0 = sp0; + ptr[1]->arr[i].unk18 = sub_8017630(&ptr[1]->arr[i].unk0, &gUnknown_082F045C); } else { - + ptr[0]->arr[i].unk0 = sp0; + ptr[0]->arr[i].unk18 = sub_8017630(&ptr[0]->arr[i].unk0, &gUnknown_082F045C); } } } -*/