From a677d1f4cb6f2925e9694b8d2b408273dcd13d9b Mon Sep 17 00:00:00 2001 From: scnorton Date: Tue, 26 Mar 2019 14:46:58 -0400 Subject: [PATCH] Failed attempt at sub_8026988 --- asm/dodrio_berry_picking.s | 300 ---------------------------- src/dodrio_berry_picking.c | 391 +++++++++++++++++++++++++++++++++++++ 2 files changed, 391 insertions(+), 300 deletions(-) diff --git a/asm/dodrio_berry_picking.s b/asm/dodrio_berry_picking.s index b802c26531..f8bfc3897f 100755 --- a/asm/dodrio_berry_picking.s +++ b/asm/dodrio_berry_picking.s @@ -5,306 +5,6 @@ .text - thumb_func_start sub_802671C -sub_802671C: @ 802671C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - ldr r2, =gUnknown_02022C98 - ldr r4, [r2] - adds r0, r4, 0 - adds r0, 0x44 - ldrb r1, [r0] - adds r0, 0x4 - ldrb r0, [r0] - mov r9, r0 - movs r3, 0 - mov r10, r3 - movs r5, 0x90 - lsls r5, 1 - adds r0, r4, r5 - str r3, [r0] - adds r5, r1, 0 - mov r0, r9 - subs r0, 0x1 - cmp r5, r0 - blt _0802674E - b _08026974 -_0802674E: - mov r8, r2 -_08026750: - mov r0, r8 - ldr r4, [r0] - adds r0, r4, 0 - adds r0, 0xC4 - adds r0, r5 - ldrb r0, [r0] - cmp r0, 0x1 - bls _08026762 - b _0802686C -_08026762: - movs r1, 0x90 - lsls r1, 1 - adds r0, r4, r1 - movs r2, 0x1 - str r2, [r0] - ldr r1, =0x000032eb - adds r0, r4, r1 - adds r6, r0, r5 - ldrb r0, [r6] - cmp r0, 0x9 - bls _080267FC - movs r7, 0 - movs r0, 0xA - strb r0, [r6] - mov r1, r8 - ldr r0, [r1] - adds r0, 0xC4 - adds r0, r5 - movs r1, 0x3 - strb r1, [r0] - mov r1, r8 - ldr r0, [r1] - movs r6, 0xA4 - lsls r6, 1 - adds r0, r6 - adds r1, r0, r5 - ldrb r0, [r1] - cmp r0, 0 - bne _080267AC - strb r2, [r1] - ldr r2, =0x000032e0 - adds r0, r4, r2 - adds r0, r5 - ldrb r0, [r0] - adds r0, 0x4A - bl PlaySE -_080267AC: - mov r0, r8 - ldr r1, [r0] - adds r0, r1, 0 - adds r0, 0x40 - ldrb r0, [r0] - cmp r0, 0x9 - bls _080267C2 - mov r2, r10 - cmp r2, 0x1 - beq _080267C2 - b _08026964 -_080267C2: - movs r0, 0x1 - mov r10, r0 - adds r0, r1, r6 - adds r0, r5 - strb r7, [r0] - mov r1, r8 - ldr r0, [r1] - adds r1, r0, 0 - adds r1, 0x40 - ldrb r0, [r1] - cmp r0, 0x9 - bhi _080267DE - adds r0, 0x1 - strb r0, [r1] -_080267DE: - movs r0, 0x3 - adds r1, r5, 0 - movs r2, 0 - bl sub_8026F1C - movs r0, 0 - bl sub_8027234 - b _08026964 - .pool -_080267FC: - adds r0, r5, 0 - bl sub_8026D8C - mov r2, r8 - ldr r7, [r2] - lsls r0, 24 - lsrs r0, 24 - adds r1, r7, 0 - adds r1, 0x90 - adds r1, r0 - ldrb r0, [r1] - movs r1, 0x7 - bl __udivsi3 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0x1 - bls _08026822 - movs r3, 0x2 -_08026822: - ldr r2, =gUnknown_082F7A88 - ldr r0, =0x000032e0 - adds r1, r4, r0 - adds r1, r5 - lsls r0, r3, 1 - adds r0, r3 - ldrb r1, [r1] - adds r0, r1 - adds r0, r2 - ldrb r2, [r0] - adds r1, r7, 0 - adds r1, 0xD0 - adds r1, r5 - ldrb r0, [r1] - adds r0, 0x1 - movs r3, 0 - strb r0, [r1] - lsls r0, 24 - lsrs r0, 24 - cmp r0, r2 - bcc _0802685C - ldrb r0, [r6] - adds r0, 0x1 - strb r0, [r6] - mov r1, r8 - ldr r0, [r1] - adds r0, 0xD0 - adds r0, r5 - strb r3, [r0] -_0802685C: - bl sub_8026324 - b _08026964 - .pool -_0802686C: - cmp r0, 0x2 - bne _080268F4 - movs r2, 0x90 - lsls r2, 1 - adds r0, r4, r2 - movs r6, 0x1 - str r6, [r0] - adds r1, r4, 0 - adds r1, 0xDC - adds r1, r5 - ldrb r0, [r1] - adds r0, 0x1 - movs r3, 0 - strb r0, [r1] - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x13 - bls _08026964 - mov r0, r8 - ldr r2, [r0] - adds r0, r2, 0 - adds r0, 0xB8 - adds r0, r5 - ldrb r1, [r0] - lsls r0, r1, 4 - subs r0, r1 - lsls r0, 2 - adds r2, r0 - ldr r1, =0x000031d0 - adds r2, r1 - strb r3, [r2] - mov r2, r8 - ldr r0, [r2] - adds r0, 0xDC - adds r0, r5 - strb r3, [r0] - ldr r0, [r2] - adds r0, 0xD0 - adds r0, r5 - strb r3, [r0] - ldr r0, [r2] - adds r0, 0xC4 - adds r0, r5 - strb r3, [r0] - ldr r1, =0x000032eb - adds r0, r4, r1 - adds r0, r5 - strb r6, [r0] - adds r0, r5, 0 - bl sub_8026D8C - lsls r0, 24 - lsrs r0, 24 - adds r1, r5, 0 - bl sub_8026DB0 - ldr r2, =0x000032e0 - adds r1, r4, r2 - adds r1, r5 - strb r0, [r1] - b _08026964 - .pool -_080268F4: - cmp r0, 0x3 - bne _08026964 - adds r1, r4, 0 - adds r1, 0xDC - adds r1, r5 - ldrb r0, [r1] - adds r0, 0x1 - movs r2, 0 - strb r0, [r1] - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x13 - bls _08026964 - mov r0, r8 - ldr r1, [r0] - adds r0, r1, 0 - adds r0, 0x40 - ldrb r0, [r0] - cmp r0, 0x9 - bhi _08026964 - adds r0, r1, 0 - adds r0, 0xDC - adds r0, r5 - strb r2, [r0] - mov r1, r8 - ldr r0, [r1] - adds r0, 0xD0 - adds r0, r5 - strb r2, [r0] - ldr r0, [r1] - adds r0, 0xC4 - adds r0, r5 - strb r2, [r0] - ldr r2, =0x000032eb - adds r0, r4, r2 - adds r0, r5 - movs r1, 0x1 - strb r1, [r0] - mov r0, r8 - ldr r1, [r0] - adds r1, 0xE8 - adds r1, r5 - subs r2, 0xB - adds r4, r2 - adds r4, r5 - ldrb r0, [r4] - strb r0, [r1] - adds r0, r5, 0 - bl sub_8026D8C - lsls r0, 24 - lsrs r0, 24 - adds r1, r5, 0 - bl sub_8026DB0 - strb r0, [r4] -_08026964: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - mov r0, r9 - subs r0, 0x1 - cmp r5, r0 - bge _08026974 - b _08026750 -_08026974: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802671C - thumb_func_start sub_8026988 sub_8026988: @ 8026988 push {r4-r7,lr} diff --git a/src/dodrio_berry_picking.c b/src/dodrio_berry_picking.c index 4d9846c167..38157aa92d 100644 --- a/src/dodrio_berry_picking.c +++ b/src/dodrio_berry_picking.c @@ -192,6 +192,7 @@ bool32 sub_8026C50(void); bool32 sub_8026C90(void); void sub_8026D1C(u8); u8 sub_8026D8C(u8); +u8 sub_8026DB0(u8, u8); void sub_8026F1C(u8, u8, u8); void sub_8027234(u8); void sub_80272A4(void); @@ -1962,3 +1963,393 @@ u32 sub_8026634(u8 a0, u8 a1, u8 a2) } return FALSE; } + +#ifdef NONMATCHING +void sub_802671C(void) +{ + u8 r1 = gUnknown_02022C98->unk_0044; + u8 r9 = gUnknown_02022C98->unk_0048; + u8 r10 = 0; + u8 i; + u8 r3; + u8 r2; + struct DodrioBerryPickingSubstruct_31A0_14 * ptr; + + gUnknown_02022C98->unk_0120 = 0; + + for (i = r1; i < r9 - 1; i++) + { + ptr = &gUnknown_02022C98->unk_32CC.unk_14; + + if (gUnknown_02022C98->unk_00C4[i] == 0 || gUnknown_02022C98->unk_00C4[i] == 1) + { + gUnknown_02022C98->unk_0120 = 1; + if (ptr->unk_B[i] >= 10) + { + ptr->unk_B[i] = 10; + gUnknown_02022C98->unk_00C4[i] = 3; + if (gUnknown_02022C98->unk_0148[i] == 0) + { + gUnknown_02022C98->unk_0148[i] = 1; + PlaySE(SE_FUUSEN1 + ptr->unk_0[i]); + } + if (gUnknown_02022C98->unk_0040 < 10 || r10 == 1) + { + r10 = 1; + gUnknown_02022C98->unk_0148[i] = 0; + if (gUnknown_02022C98->unk_0040 < 10) + { + gUnknown_02022C98->unk_0040++; + } + sub_8026F1C(3, i, 0); + sub_8027234(0); + } + } + else + { + r3 = gUnknown_02022C98->unk_0090[sub_8026D8C(i)] / 7; + if (r3 < 2) + { + r3 = 2; + } + r2 = gUnknown_082F7A88[r3][ptr->unk_0[i]]; + if (++gUnknown_02022C98->unk_00D0[i] >= r2) + { + ptr->unk_B[i]++; + gUnknown_02022C98->unk_00D0[i] = 0; + } + sub_8026324(); + } + } + else if (gUnknown_02022C98->unk_00C4[i] == 2) + { + gUnknown_02022C98->unk_0120 = 1; + if (++gUnknown_02022C98->unk_00DC[i] >= 20) + { + gUnknown_02022C98->unk_31A0[gUnknown_02022C98->unk_00B8[i]].unk_30 = 0; + gUnknown_02022C98->unk_00DC[i] = 0; + gUnknown_02022C98->unk_00D0[i] = 0; + gUnknown_02022C98->unk_00C4[i] = 0; + ptr->unk_B[i] = 1; + ptr->unk_0[i] = sub_8026DB0(sub_8026D8C(i), i); + } + } + else if (gUnknown_02022C98->unk_00C4[i] == 3) + { + if (++gUnknown_02022C98->unk_00DC[i] >= 20) + { + if (gUnknown_02022C98->unk_0040 < 10) + { + gUnknown_02022C98->unk_00DC[i] = 0; + gUnknown_02022C98->unk_00D0[i] = 0; + gUnknown_02022C98->unk_00C4[i] = 0; + ptr->unk_B[i] = 1; + gUnknown_02022C98->unk_00E8[i] = ptr->unk_0[i]; + ptr->unk_0[i] = sub_8026DB0(sub_8026D8C(i), i); + } + } + } + } +} +#else +NAKED +void sub_802671C(void) +{ + asm_unified("\tpush {r4-r7,lr}\n" + "\tmov r7, r10\n" + "\tmov r6, r9\n" + "\tmov r5, r8\n" + "\tpush {r5-r7}\n" + "\tldr r2, =gUnknown_02022C98\n" + "\tldr r4, [r2]\n" + "\tadds r0, r4, 0\n" + "\tadds r0, 0x44\n" + "\tldrb r1, [r0]\n" + "\tadds r0, 0x4\n" + "\tldrb r0, [r0]\n" + "\tmov r9, r0\n" + "\tmovs r3, 0\n" + "\tmov r10, r3\n" + "\tmovs r5, 0x90\n" + "\tlsls r5, 1\n" + "\tadds r0, r4, r5\n" + "\tstr r3, [r0]\n" + "\tadds r5, r1, 0\n" + "\tmov r0, r9\n" + "\tsubs r0, 0x1\n" + "\tcmp r5, r0\n" + "\tblt _0802674E\n" + "\tb _08026974\n" + "_0802674E:\n" + "\tmov r8, r2\n" + "_08026750:\n" + "\tmov r0, r8\n" + "\tldr r4, [r0]\n" + "\tadds r0, r4, 0\n" + "\tadds r0, 0xC4\n" + "\tadds r0, r5\n" + "\tldrb r0, [r0]\n" + "\tcmp r0, 0x1\n" + "\tbls _08026762\n" + "\tb _0802686C\n" + "_08026762:\n" + "\tmovs r1, 0x90\n" + "\tlsls r1, 1\n" + "\tadds r0, r4, r1\n" + "\tmovs r2, 0x1\n" + "\tstr r2, [r0]\n" + "\tldr r1, =0x000032eb\n" + "\tadds r0, r4, r1\n" + "\tadds r6, r0, r5\n" + "\tldrb r0, [r6]\n" + "\tcmp r0, 0x9\n" + "\tbls _080267FC\n" + "\tmovs r7, 0\n" + "\tmovs r0, 0xA\n" + "\tstrb r0, [r6]\n" + "\tmov r1, r8\n" + "\tldr r0, [r1]\n" + "\tadds r0, 0xC4\n" + "\tadds r0, r5\n" + "\tmovs r1, 0x3\n" + "\tstrb r1, [r0]\n" + "\tmov r1, r8\n" + "\tldr r0, [r1]\n" + "\tmovs r6, 0xA4\n" + "\tlsls r6, 1\n" + "\tadds r0, r6\n" + "\tadds r1, r0, r5\n" + "\tldrb r0, [r1]\n" + "\tcmp r0, 0\n" + "\tbne _080267AC\n" + "\tstrb r2, [r1]\n" + "\tldr r2, =0x000032e0\n" + "\tadds r0, r4, r2\n" + "\tadds r0, r5\n" + "\tldrb r0, [r0]\n" + "\tadds r0, 0x4A\n" + "\tbl PlaySE\n" + "_080267AC:\n" + "\tmov r0, r8\n" + "\tldr r1, [r0]\n" + "\tadds r0, r1, 0\n" + "\tadds r0, 0x40\n" + "\tldrb r0, [r0]\n" + "\tcmp r0, 0x9\n" + "\tbls _080267C2\n" + "\tmov r2, r10\n" + "\tcmp r2, 0x1\n" + "\tbeq _080267C2\n" + "\tb _08026964\n" + "_080267C2:\n" + "\tmovs r0, 0x1\n" + "\tmov r10, r0\n" + "\tadds r0, r1, r6\n" + "\tadds r0, r5\n" + "\tstrb r7, [r0]\n" + "\tmov r1, r8\n" + "\tldr r0, [r1]\n" + "\tadds r1, r0, 0\n" + "\tadds r1, 0x40\n" + "\tldrb r0, [r1]\n" + "\tcmp r0, 0x9\n" + "\tbhi _080267DE\n" + "\tadds r0, 0x1\n" + "\tstrb r0, [r1]\n" + "_080267DE:\n" + "\tmovs r0, 0x3\n" + "\tadds r1, r5, 0\n" + "\tmovs r2, 0\n" + "\tbl sub_8026F1C\n" + "\tmovs r0, 0\n" + "\tbl sub_8027234\n" + "\tb _08026964\n" + "\t.pool\n" + "_080267FC:\n" + "\tadds r0, r5, 0\n" + "\tbl sub_8026D8C\n" + "\tmov r2, r8\n" + "\tldr r7, [r2]\n" + "\tlsls r0, 24\n" + "\tlsrs r0, 24\n" + "\tadds r1, r7, 0\n" + "\tadds r1, 0x90\n" + "\tadds r1, r0\n" + "\tldrb r0, [r1]\n" + "\tmovs r1, 0x7\n" + "\tbl __udivsi3\n" + "\tlsls r0, 24\n" + "\tlsrs r3, r0, 24\n" + "\tcmp r3, 0x1\n" + "\tbls _08026822\n" + "\tmovs r3, 0x2\n" + "_08026822:\n" + "\tldr r2, =gUnknown_082F7A88\n" + "\tldr r0, =0x000032e0\n" + "\tadds r1, r4, r0\n" + "\tadds r1, r5\n" + "\tlsls r0, r3, 1\n" + "\tadds r0, r3\n" + "\tldrb r1, [r1]\n" + "\tadds r0, r1\n" + "\tadds r0, r2\n" + "\tldrb r2, [r0]\n" + "\tadds r1, r7, 0\n" + "\tadds r1, 0xD0\n" + "\tadds r1, r5\n" + "\tldrb r0, [r1]\n" + "\tadds r0, 0x1\n" + "\tmovs r3, 0\n" + "\tstrb r0, [r1]\n" + "\tlsls r0, 24\n" + "\tlsrs r0, 24\n" + "\tcmp r0, r2\n" + "\tbcc _0802685C\n" + "\tldrb r0, [r6]\n" + "\tadds r0, 0x1\n" + "\tstrb r0, [r6]\n" + "\tmov r1, r8\n" + "\tldr r0, [r1]\n" + "\tadds r0, 0xD0\n" + "\tadds r0, r5\n" + "\tstrb r3, [r0]\n" + "_0802685C:\n" + "\tbl sub_8026324\n" + "\tb _08026964\n" + "\t.pool\n" + "_0802686C:\n" + "\tcmp r0, 0x2\n" + "\tbne _080268F4\n" + "\tmovs r2, 0x90\n" + "\tlsls r2, 1\n" + "\tadds r0, r4, r2\n" + "\tmovs r6, 0x1\n" + "\tstr r6, [r0]\n" + "\tadds r1, r4, 0\n" + "\tadds r1, 0xDC\n" + "\tadds r1, r5\n" + "\tldrb r0, [r1]\n" + "\tadds r0, 0x1\n" + "\tmovs r3, 0\n" + "\tstrb r0, [r1]\n" + "\tlsls r0, 24\n" + "\tlsrs r0, 24\n" + "\tcmp r0, 0x13\n" + "\tbls _08026964\n" + "\tmov r0, r8\n" + "\tldr r2, [r0]\n" + "\tadds r0, r2, 0\n" + "\tadds r0, 0xB8\n" + "\tadds r0, r5\n" + "\tldrb r1, [r0]\n" + "\tlsls r0, r1, 4\n" + "\tsubs r0, r1\n" + "\tlsls r0, 2\n" + "\tadds r2, r0\n" + "\tldr r1, =0x000031d0\n" + "\tadds r2, r1\n" + "\tstrb r3, [r2]\n" + "\tmov r2, r8\n" + "\tldr r0, [r2]\n" + "\tadds r0, 0xDC\n" + "\tadds r0, r5\n" + "\tstrb r3, [r0]\n" + "\tldr r0, [r2]\n" + "\tadds r0, 0xD0\n" + "\tadds r0, r5\n" + "\tstrb r3, [r0]\n" + "\tldr r0, [r2]\n" + "\tadds r0, 0xC4\n" + "\tadds r0, r5\n" + "\tstrb r3, [r0]\n" + "\tldr r1, =0x000032eb\n" + "\tadds r0, r4, r1\n" + "\tadds r0, r5\n" + "\tstrb r6, [r0]\n" + "\tadds r0, r5, 0\n" + "\tbl sub_8026D8C\n" + "\tlsls r0, 24\n" + "\tlsrs r0, 24\n" + "\tadds r1, r5, 0\n" + "\tbl sub_8026DB0\n" + "\tldr r2, =0x000032e0\n" + "\tadds r1, r4, r2\n" + "\tadds r1, r5\n" + "\tstrb r0, [r1]\n" + "\tb _08026964\n" + "\t.pool\n" + "_080268F4:\n" + "\tcmp r0, 0x3\n" + "\tbne _08026964\n" + "\tadds r1, r4, 0\n" + "\tadds r1, 0xDC\n" + "\tadds r1, r5\n" + "\tldrb r0, [r1]\n" + "\tadds r0, 0x1\n" + "\tmovs r2, 0\n" + "\tstrb r0, [r1]\n" + "\tlsls r0, 24\n" + "\tlsrs r0, 24\n" + "\tcmp r0, 0x13\n" + "\tbls _08026964\n" + "\tmov r0, r8\n" + "\tldr r1, [r0]\n" + "\tadds r0, r1, 0\n" + "\tadds r0, 0x40\n" + "\tldrb r0, [r0]\n" + "\tcmp r0, 0x9\n" + "\tbhi _08026964\n" + "\tadds r0, r1, 0\n" + "\tadds r0, 0xDC\n" + "\tadds r0, r5\n" + "\tstrb r2, [r0]\n" + "\tmov r1, r8\n" + "\tldr r0, [r1]\n" + "\tadds r0, 0xD0\n" + "\tadds r0, r5\n" + "\tstrb r2, [r0]\n" + "\tldr r0, [r1]\n" + "\tadds r0, 0xC4\n" + "\tadds r0, r5\n" + "\tstrb r2, [r0]\n" + "\tldr r2, =0x000032eb\n" + "\tadds r0, r4, r2\n" + "\tadds r0, r5\n" + "\tmovs r1, 0x1\n" + "\tstrb r1, [r0]\n" + "\tmov r0, r8\n" + "\tldr r1, [r0]\n" + "\tadds r1, 0xE8\n" + "\tadds r1, r5\n" + "\tsubs r2, 0xB\n" + "\tadds r4, r2\n" + "\tadds r4, r5\n" + "\tldrb r0, [r4]\n" + "\tstrb r0, [r1]\n" + "\tadds r0, r5, 0\n" + "\tbl sub_8026D8C\n" + "\tlsls r0, 24\n" + "\tlsrs r0, 24\n" + "\tadds r1, r5, 0\n" + "\tbl sub_8026DB0\n" + "\tstrb r0, [r4]\n" + "_08026964:\n" + "\tadds r0, r5, 0x1\n" + "\tlsls r0, 24\n" + "\tlsrs r5, r0, 24\n" + "\tmov r0, r9\n" + "\tsubs r0, 0x1\n" + "\tcmp r5, r0\n" + "\tbge _08026974\n" + "\tb _08026750\n" + "_08026974:\n" + "\tpop {r3-r5}\n" + "\tmov r8, r3\n" + "\tmov r9, r4\n" + "\tmov r10, r5\n" + "\tpop {r4-r7}\n" + "\tpop {r0}\n" + "\tbx r0\n" + "\t.pool"); +} +#endif // NONMATCHING