From 98ab62a7afd49fb207820aa12035aac44d008a9e Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 24 Mar 2019 16:42:42 -0400 Subject: [PATCH 01/13] Dodrio: through sub_8024A30 --- asm/dodrio_berry_picking.s | 303 ------------------------------------- ld_script.txt | 2 + src/dodrio_berry_picking.c | 183 ++++++++++++++++++++++ src/union_room.c | 1 - sym_bss.txt | 1 + sym_ewram.txt | 3 +- 6 files changed, 187 insertions(+), 306 deletions(-) create mode 100644 src/dodrio_berry_picking.c diff --git a/asm/dodrio_berry_picking.s b/asm/dodrio_berry_picking.s index e52e7a347..bcb250567 100755 --- a/asm/dodrio_berry_picking.s +++ b/asm/dodrio_berry_picking.s @@ -5,309 +5,6 @@ .text - thumb_func_start sub_802493C -sub_802493C: @ 802493C - push {r4-r6,lr} - adds r5, r1, 0 - lsls r0, 16 - lsrs r6, r0, 16 - ldr r1, =gUnknown_03000DB0 - movs r0, 0 - str r0, [r1] - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - beq _08024A10 - ldr r4, =gUnknown_02022C98 - ldr r0, =0x00003330 - bl AllocZeroed - str r0, [r4] - cmp r0, 0 - beq _08024A10 - bl sub_8024A1C - ldr r0, [r4] - bl sub_8024A30 - ldr r0, [r4] - str r5, [r0] - bl GetMultiplayerId - ldr r1, [r4] - adds r1, 0x28 - strb r0, [r1] - ldr r1, [r4] - ldr r2, =0x000032cc - adds r0, r1, r2 - adds r2, r1, 0 - adds r2, 0x28 - ldrb r3, [r2] - lsls r2, r3, 4 - subs r2, r3 - lsls r2, 2 - adds r1, r2 - ldr r2, =0x000031a0 - adds r1, r2 - movs r2, 0x3C - bl memcpy - ldr r0, [r4] - adds r1, r0, 0 - adds r1, 0x28 - ldrb r1, [r1] - lsls r1, 2 - ldr r2, =0x0000318c - adds r1, r2 - adds r0, r1 - movs r1, 0x64 - muls r1, r6 - ldr r2, =gPlayerParty - adds r1, r2 - bl sub_80261F8 - ldr r0, =sub_8024BC8 - movs r1, 0x1 - bl CreateTask - ldr r0, =sub_80261CC - bl SetMainCallback2 - bl sub_80273F0 - ldr r2, [r4] - adds r0, r2, 0 - adds r0, 0x24 - ldrb r0, [r0] - adds r1, r2, 0 - adds r1, 0x44 - adds r2, 0x48 - bl sub_8026B5C - bl StopMapMusic - ldr r0, =0x0000021e - bl PlayNewMapMusic - b _08024A16 - .pool -_08024A10: - adds r0, r5, 0 - bl SetMainCallback2 -_08024A16: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_802493C - - thumb_func_start sub_8024A1C -sub_8024A1C: @ 8024A1C - push {lr} - bl ResetTasks - bl ResetSpriteData - bl FreeAllSpritePalettes - pop {r0} - bx r0 - thumb_func_end sub_8024A1C - - thumb_func_start sub_8024A30 -sub_8024A30: @ 8024A30 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x28 - adds r2, r0, 0 - movs r0, 0 - strb r0, [r2, 0xC] - strb r0, [r2, 0x10] - strb r0, [r2, 0x14] - strb r0, [r2, 0x18] - strb r0, [r2, 0x1C] - movs r3, 0x8E - lsls r3, 1 - adds r1, r2, r3 - str r0, [r1] - movs r7, 0x90 - lsls r7, 1 - adds r1, r2, r7 - str r0, [r1] - adds r1, r2, 0 - adds r1, 0x30 - strb r0, [r1] - adds r1, 0x10 - strb r0, [r1] - subs r1, 0x4 - strb r0, [r1] - adds r3, 0x10 - adds r1, r2, r3 - str r0, [r1] - movs r5, 0 - adds r1, r2, 0 - adds r1, 0x98 - movs r3, 0 -_08024A76: - adds r0, r1, r5 - strb r3, [r0] - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x3 - bls _08024A76 - movs r5, 0 - adds r7, r2, 0 - adds r7, 0xA8 - str r7, [sp] - adds r0, r2, 0 - adds r0, 0xB0 - str r0, [sp, 0xC] - movs r1, 0x4A - adds r1, r2 - mov r10, r1 - movs r3, 0x4C - adds r3, r2 - mov r9, r3 - movs r7, 0x4E - adds r7, r2 - mov r12, r7 - subs r0, 0x60 - str r0, [sp, 0x24] - adds r6, r2, 0 - adds r6, 0x54 - adds r1, r2, 0 - adds r1, 0xD0 - str r1, [sp, 0x1C] - adds r3, r2, 0 - adds r3, 0xDC - str r3, [sp, 0x20] - adds r7, r2, 0 - adds r7, 0xC4 - str r7, [sp, 0x14] - adds r0, 0xA4 - str r0, [sp, 0x4] - adds r1, 0x25 - str r1, [sp, 0x8] - subs r3, 0xBC - str r3, [sp, 0x10] - movs r7, 0x24 - adds r7, r2 - mov r8, r7 - subs r0, 0xC0 - str r0, [sp, 0x18] - movs r3, 0 - movs r1, 0x86 - lsls r1, 1 - adds r4, r2, r1 - movs r7, 0x98 - lsls r7, 1 - adds r2, r7 -_08024AE2: - ldr r1, [sp] - adds r0, r1, r5 - strb r3, [r0] - ldr r7, [sp, 0xC] - adds r0, r7, r5 - strb r3, [r0] - lsls r0, r5, 1 - adds r0, r5 - lsls r0, 2 - mov r7, r10 - adds r1, r7, r0 - strh r3, [r1] - mov r7, r9 - adds r1, r7, r0 - strh r3, [r1] - mov r7, r12 - adds r1, r7, r0 - strh r3, [r1] - ldr r7, [sp, 0x24] - adds r1, r7, r0 - strh r3, [r1] - adds r0, r6, r0 - strh r3, [r0] - adds r0, r4, r5 - strb r3, [r0] - lsls r0, r5, 2 - adds r0, r2, r0 - str r3, [r0] - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x4 - bls _08024AE2 - movs r5, 0 - movs r3, 0 - movs r4, 0xFF - ldr r6, [sp, 0x1C] -_08024B2C: - adds r0, r6, r5 - strb r3, [r0] - ldr r1, [sp, 0x20] - adds r0, r1, r5 - strb r3, [r0] - ldr r7, [sp, 0x14] - adds r0, r7, r5 - strb r3, [r0] - lsls r1, r5, 1 - ldr r0, [sp, 0x4] - adds r2, r0, r1 - ldrb r0, [r2] - orrs r0, r4 - strb r0, [r2] - ldr r7, [sp, 0x8] - adds r1, r7, r1 - ldrb r0, [r1] - orrs r0, r4 - strb r0, [r1] - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0xA - bls _08024B2C - bl GetMultiplayerId - movs r1, 0 - lsls r0, 24 - cmp r0, 0 - bne _08024B6A - movs r1, 0x1 -_08024B6A: - ldr r0, [sp, 0x10] - strb r1, [r0] - bl GetLinkPlayerCount - mov r1, r8 - strb r0, [r1] - bl GetMultiplayerId - ldr r3, [sp, 0x18] - strb r0, [r3] - movs r5, 0x1 - mov r7, r8 - ldrb r7, [r7] - cmp r5, r7 - bcs _08024BB6 - ldr r7, [sp, 0x18] - mov r6, r8 -_08024B8C: - adds r4, r7, r5 - subs r0, r5, 0x1 - adds r0, r7, r0 - ldrb r0, [r0] - adds r0, 0x1 - strb r0, [r4] - ldrb r2, [r4] - ldrb r1, [r6] - subs r0, r1, 0x1 - cmp r2, r0 - ble _08024BAA - adds r0, r2, 0 - bl __umodsi3 - strb r0, [r4] -_08024BAA: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - ldrb r0, [r6] - cmp r5, r0 - bcc _08024B8C -_08024BB6: - add sp, 0x28 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8024A30 - thumb_func_start sub_8024BC8 sub_8024BC8: @ 8024BC8 push {r4,r5,lr} diff --git a/ld_script.txt b/ld_script.txt index a78890b9f..88d49b4f3 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -65,6 +65,7 @@ SECTIONS { asm/union_room_chat.o(.text); asm/berry_crush.o(.text); asm/berry_powder_vendor.o(.text); + src/dodrio_berry_picking.o(.text); asm/dodrio_berry_picking.o(.text); asm/pokemon_jump.o(.text); src/rtc.o(.text); @@ -414,6 +415,7 @@ SECTIONS { data/union_room_chat.o(.rodata); data/berry_crush.o(.rodata); data/berry_powder_vendor.o(.rodata); + src/dodrio_berry_picking.o(.rodata); data/dodrio_berry_picking.o(.rodata); data/pokemon_jump.o(.rodata); src/rtc.o(.rodata); diff --git a/src/dodrio_berry_picking.c b/src/dodrio_berry_picking.c new file mode 100644 index 000000000..6f4960877 --- /dev/null +++ b/src/dodrio_berry_picking.c @@ -0,0 +1,183 @@ +#include "global.h" +#include "alloc.h" +#include "link.h" +#include "task.h" +#include "main.h" +#include "constants/songs.h" +#include "sound.h" + +struct DodrioBerryPickingSubstruct_004A +{ + /*0x00*/ u16 unk00; + /*0x02*/ u8 filler02[10]; +}; // size = 0x0C + +struct DodrioBerryPickingSubstruct_31A0 +{ + u8 unk_00[0x3C - 0x00]; +}; // size = 0x3C + +struct DodrioBerryPickingSubstruct_318C +{ + bool8 isShiny; +}; + +struct DodrioBerryPickingStruct +{ + /*0x0000*/ void (*savedCallback)(void); + /*0x0004*/ u8 filler_0004[8]; + /*0x000C*/ u8 unk_000C; + /*0x000D*/ u8 filler_000D[3]; + /*0x0010*/ u8 unk_0010; + /*0x0011*/ u8 filler_0011[3]; + /*0x0014*/ u8 unk_0014; + /*0x0015*/ u8 filler_0015[3]; + /*0x0018*/ u8 unk_0018; + /*0x0019*/ u8 filler_0019[3]; + /*0x001C*/ u8 unk_001C; + /*0x001D*/ u8 filler_001D[3]; + /*0x0020*/ u8 unk_0020; + /*0x0021*/ u8 filler_0021[3]; + /*0x0024*/ u8 unk_0024; + /*0x0025*/ u8 filler_0025[3]; + /*0x0028*/ u8 multiplayerId; + /*0x0029*/ u8 filler_0029[7]; + /*0x0030*/ u8 unk_0030; + /*0x0031*/ u8 filler_0031[3]; + /*0x0034*/ u8 unk_0034[5]; + /*0x0039*/ u8 filler_0039[3]; + /*0x003C*/ u8 unk_003C; + /*0x003D*/ u8 filler_003D[3]; + /*0x0040*/ u8 unk_0040; + /*0x0041*/ u8 filler_0041[3]; + /*0x0044*/ u8 unk_0044; + /*0x0045*/ u8 filler_0045[3]; + /*0x0048*/ u8 unk_0048; + // align 1 + /*0x004A*/ u16 unk_004A[5][6]; + /*0x0086*/ u8 filler_0086[18]; + /*0x0098*/ u8 unk_0098[4]; + /*0x009C*/ u8 filler_009C[12]; + /*0x00A8*/ u8 unk_00A8[5]; + /*0x00AD*/ u8 filler_00AD[3]; + /*0x00B0*/ u8 unk_00B0[5]; + /*0x00B5*/ u8 filler_00B5[0xC4 - 0xB5]; + /*0x00C4*/ u8 unk_00C4[11]; + /*0x00CF*/ u8 filler_00CF[1]; + /*0x00D0*/ u8 unk_00D0[11]; + /*0x00DB*/ u8 filler_00DB[1]; + /*0x00DC*/ u8 unk_00DC[11]; + /*0x00E7*/ u8 filler_0xE7[0xF4 - 0xE7]; + /*0x00F4*/ u8 unk_00F4[11][2]; + /*0x010A*/ u8 filler_010A[2]; + /*0x010C*/ u8 unk_010C[5]; + /*0x0111*/ u8 filler_0111[11]; + /*0x011C*/ u32 unk_011C; + /*0x0120*/ u32 unk_0120; + /*0x0124*/ u8 filler_0124[8]; + /*0x012C*/ u32 unk_012C; + /*0x0130*/ u32 unk_0130[5]; + /*0x0144*/ u8 filler_0144[0x318C - 0x0144]; + /*0x318C*/ struct DodrioBerryPickingSubstruct_318C unk_318C[5]; + /*0x31A0*/ struct DodrioBerryPickingSubstruct_31A0 unk_31A0[5]; + /*0x32CC*/ struct DodrioBerryPickingSubstruct_31A0 unk_32CC; + /*0x3308*/ u8 unk_3308[0x3330 - 0x3308]; +}; // size = 0x3330 + +EWRAM_DATA struct DodrioBerryPickingStruct * gUnknown_02022C98 = NULL; +IWRAM_DATA bool32 gUnknown_03000DB0; + +void sub_8024A1C(void); +void sub_8024A30(struct DodrioBerryPickingStruct *); +void sub_8024BC8(u8 taskId); +void sub_80261F8(struct DodrioBerryPickingSubstruct_318C *, struct Pokemon *); +void sub_80261CC(void); +void sub_8026B5C(u8, u8*, u8*); +void sub_80273F0(void); + +void sub_802493C(u16 a0, void (*a1)(void)) +{ + gUnknown_03000DB0 = FALSE; + + if (gReceivedRemoteLinkPlayers != 0 && (gUnknown_02022C98 = AllocZeroed(sizeof(*gUnknown_02022C98))) != NULL) + { + sub_8024A1C(); + sub_8024A30(gUnknown_02022C98); + gUnknown_02022C98->savedCallback = a1; + gUnknown_02022C98->multiplayerId = GetMultiplayerId(); + gUnknown_02022C98->unk_32CC = gUnknown_02022C98->unk_31A0[gUnknown_02022C98->multiplayerId]; + sub_80261F8(&gUnknown_02022C98->unk_318C[gUnknown_02022C98->multiplayerId], &gPlayerParty[a0]); + CreateTask(sub_8024BC8, 1); + SetMainCallback2(sub_80261CC); + sub_80273F0(); + sub_8026B5C(gUnknown_02022C98->unk_0024, &gUnknown_02022C98->unk_0044, &gUnknown_02022C98->unk_0048); + StopMapMusic(); + PlayNewMapMusic(MUS_RG_KINOMIKUI); + } + else + { + SetMainCallback2(a1); + return; + } +} + +void sub_8024A1C(void) +{ + ResetTasks(); + ResetSpriteData(); + FreeAllSpritePalettes(); +} + +void sub_8024A30(struct DodrioBerryPickingStruct * data) +{ + u8 i; + + data->unk_000C = 0; + data->unk_0010 = 0; + data->unk_0014 = 0; + data->unk_0018 = 0; + data->unk_001C = 0; + data->unk_011C = 0; + data->unk_0120 = 0; + data->unk_0030 = 0; + data->unk_0040 = 0; + data->unk_003C = 0; + data->unk_012C = 0; + + for (i = 0; i < 4; i++) + { + data->unk_0098[i] = 0; + } + + for (i = 0; i < 5; i++) + { + data->unk_00A8[i] = 0; + data->unk_00B0[i] = 0; + data->unk_004A[i][0] = 0; + data->unk_004A[i][1] = 0; + data->unk_004A[i][2] = 0; + data->unk_004A[i][3] = 0; + data->unk_004A[i][5] = 0; + data->unk_010C[i] = 0; + data->unk_0130[i] = 0; + } + + for (i = 0; i < 11; i++) + { + data->unk_00D0[i] = 0; + data->unk_00DC[i] = 0; + data->unk_00C4[i] = 0; + data->unk_00F4[i][0] = 0xFF; + data->unk_00F4[i][1] = 0xFF; + } + + data->unk_0020 = GetMultiplayerId() == 0 ? 1 : 0; + data->unk_0024 = GetLinkPlayerCount(); + data->unk_0034[0] = GetMultiplayerId(); + for (i = 1; i < data->unk_0024; i++) + { + data->unk_0034[i] = data->unk_0034[i - 1] + 1; + if (data->unk_0034[i] > data->unk_0024 - 1) + data->unk_0034[i] %= data->unk_0024; + } +} diff --git a/src/union_room.c b/src/union_room.c index 51d48fdcf..68a517ea6 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -194,7 +194,6 @@ IWRAM_DATA struct UnkStruct_Leader *gUnknown_03000DA0; IWRAM_DATA struct UnkStruct_Group *gUnknown_03000DA4; IWRAM_DATA struct UnkStruct_URoom *gUnknown_03000DA8; IWRAM_DATA void *gUnknown_03000DAC; -IWRAM_DATA bool32 gUnknown_03000DB0; // this file's functions void sub_80173E0(u8 windowId, u8 arg1, const u8 *str, u8 arg3, u8 arg4, u8 arg5); diff --git a/sym_bss.txt b/sym_bss.txt index 1eef0130b..5117ab19d 100644 --- a/sym_bss.txt +++ b/sym_bss.txt @@ -8,6 +8,7 @@ .include "src/link.o" .include "src/link_rfu.o" .include "src/union_room.o" + .include "src/dodrio_berry_picking.o" .include "src/rtc.o" .include "src/main_menu.o" .include "src/rom_8034C54.o" diff --git a/sym_ewram.txt b/sym_ewram.txt index e4b315c92..937568855 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -76,8 +76,7 @@ gUnknown_02022C90: @ 2022C90 gUnknown_02022C94: @ 2022C94 .space 0x4 -gUnknown_02022C98: @ 2022C98 - .space 0x4 + .include "src/dodrio_berry_picking.o" gUnknown_02022C9C: @ 2022C9C .space 0x14 From 2136187c113be3c1bc0627c23915f88e0c8a6fc7 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 24 Mar 2019 17:32:59 -0400 Subject: [PATCH 02/13] sub_8024BC8 --- asm/dodrio_berry_picking.s | 168 ------------------------------------- asmdiff.sh | 2 +- src/dodrio_berry_picking.c | 117 ++++++++++++++++++++++++-- sym_ewram.txt | 18 ---- 4 files changed, 113 insertions(+), 192 deletions(-) diff --git a/asm/dodrio_berry_picking.s b/asm/dodrio_berry_picking.s index bcb250567..7155edf1b 100755 --- a/asm/dodrio_berry_picking.s +++ b/asm/dodrio_berry_picking.s @@ -5,174 +5,6 @@ .text - thumb_func_start sub_8024BC8 -sub_8024BC8: @ 8024BC8 - push {r4,r5,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r1, r0, 24 - ldr r0, =gUnknown_02022C98 - ldr r0, [r0] - ldrb r0, [r0, 0xC] - cmp r0, 0x7 - bls _08024BDC - b _08024D34 -_08024BDC: - lsls r0, 2 - ldr r1, =_08024BF0 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08024BF0: - .4byte _08024C10 - .4byte _08024C24 - .4byte _08024C4C - .4byte _08024C5A - .4byte _08024C80 - .4byte _08024CD4 - .4byte _08024CE6 - .4byte _08024D10 -_08024C10: - movs r0, 0 - bl SetVBlankCallback - ldr r0, =sub_8025910 - movs r1, 0x4 - bl sub_802620C - b _08024D20 - .pool -_08024C24: - ldr r0, =sub_8025910 - bl FuncIsActiveTask - lsls r0, 24 - cmp r0, 0 - beq _08024C32 - b _08024D40 -_08024C32: - ldr r4, =gUnknown_02022C98 - ldr r0, [r4] - movs r1, 0xB0 - lsls r1, 1 - adds r0, r1 - bl sub_8029274 - ldr r1, [r4] - b _08024D24 - .pool -_08024C4C: - bl sub_802A770 - cmp r0, 0 - bne _08024D40 - bl sub_8010434 - b _08024D20 -_08024C5A: - bl IsLinkTaskFinished - lsls r0, 24 - cmp r0, 0 - beq _08024D40 - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - beq _08024D20 - bl sub_800E0E8 - movs r0, 0 - movs r1, 0 - bl CreateWirelessStatusIndicatorSprite - b _08024D20 - .pool -_08024C80: - ldr r0, =gUnknown_02022C98 - ldr r0, [r0] - adds r0, 0x24 - ldrb r5, [r0] - bl sub_80283A8 - movs r4, 0 - cmp r4, r5 - bcs _08024CBA -_08024C92: - ldr r0, =gUnknown_02022C98 - ldr r1, [r0] - adds r0, r1, 0 - adds r0, 0x34 - adds r0, r4 - ldrb r2, [r0] - lsls r0, r2, 2 - ldr r3, =0x0000318c - adds r0, r3 - adds r0, r1, r0 - adds r1, 0x24 - ldrb r3, [r1] - adds r1, r4, 0 - bl sub_8028408 - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, r5 - bcc _08024C92 -_08024CBA: - ldr r4, =gUnknown_02022C98 - ldr r0, [r4] - adds r0, 0x24 - ldrb r1, [r0] - movs r0, 0 - bl sub_802868C - ldr r1, [r4] - b _08024D24 - .pool -_08024CD4: - bl sub_8028A34 - bl sub_8028A88 - bl sub_8028D44 - bl sub_8028734 - b _08024D20 -_08024CE6: - movs r4, 0x1 - negs r4, r4 - adds r0, r4, 0 - movs r1, 0x10 - movs r2, 0 - bl BlendPalettes - movs r0, 0 - str r0, [sp] - adds r0, r4, 0 - movs r1, 0 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - ldr r0, =sub_80261E4 - bl SetVBlankCallback - b _08024D20 - .pool -_08024D10: - bl UpdatePaletteFade - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08024D40 -_08024D20: - ldr r0, =gUnknown_02022C98 - ldr r1, [r0] -_08024D24: - ldrb r0, [r1, 0xC] - adds r0, 0x1 - strb r0, [r1, 0xC] - b _08024D40 - .pool -_08024D34: - adds r0, r1, 0 - bl DestroyTask - ldr r0, =sub_802589C - bl sub_802621C -_08024D40: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8024BC8 - thumb_func_start sub_8024D4C sub_8024D4C: @ 8024D4C push {lr} diff --git a/asmdiff.sh b/asmdiff.sh index 1d2141c32..9e8749acf 100755 --- a/asmdiff.sh +++ b/asmdiff.sh @@ -4,4 +4,4 @@ OBJDUMP="$DEVKITARM/bin/arm-none-eabi-objdump -D -bbinary -marmv4t -Mforce-thumb OPTIONS="--start-address=$(($1)) --stop-address=$(($1 + $2))" $OBJDUMP $OPTIONS baserom.gba > baserom.dump $OBJDUMP $OPTIONS pokeemerald.gba > pokeemerald.dump -diff baserom.dump pokeemerald.dump +diff -u baserom.dump pokeemerald.dump diff --git a/src/dodrio_berry_picking.c b/src/dodrio_berry_picking.c index 6f4960877..eef4ec262 100644 --- a/src/dodrio_berry_picking.c +++ b/src/dodrio_berry_picking.c @@ -1,16 +1,28 @@ #include "global.h" #include "alloc.h" +#include "palette.h" #include "link.h" +#include "link_rfu.h" #include "task.h" #include "main.h" #include "constants/songs.h" #include "sound.h" -struct DodrioBerryPickingSubstruct_004A +struct DodrioBerryPickingSubstruct_0160 { - /*0x00*/ u16 unk00; - /*0x02*/ u8 filler02[10]; -}; // size = 0x0C + /*0x0000 : 0x0160*/ u8 filler_000[12]; + /*0x000C : 0x016C*/ u8 unk_00C; + /*0x000D : 0x016D*/ u8 filler_00D[0x3000 - 0xd]; + /*0x3000 : 0x3160*/ u32 unk_3000; + /*0x3004 : 0x3164*/ u8 filler_3004[16]; + /*0x3014 : 0x3174*/ u8 unk_3014; + /*0x3015 : 0x3175*/ u8 filler_3015[0x318C - 0x3175]; +}; // size = 0x302C + +struct DodrioBerryPickingStruct_2022CF4 +{ + u8 filler_00[0x40]; +}; // size = 0x40 struct DodrioBerryPickingSubstruct_31A0 { @@ -77,7 +89,8 @@ struct DodrioBerryPickingStruct /*0x0124*/ u8 filler_0124[8]; /*0x012C*/ u32 unk_012C; /*0x0130*/ u32 unk_0130[5]; - /*0x0144*/ u8 filler_0144[0x318C - 0x0144]; + /*0x0144*/ u8 filler_0144[0x1C]; + /*0x0160*/ struct DodrioBerryPickingSubstruct_0160 unk_0160; /*0x318C*/ struct DodrioBerryPickingSubstruct_318C unk_318C[5]; /*0x31A0*/ struct DodrioBerryPickingSubstruct_31A0 unk_31A0[5]; /*0x32CC*/ struct DodrioBerryPickingSubstruct_31A0 unk_32CC; @@ -85,6 +98,13 @@ struct DodrioBerryPickingStruct }; // size = 0x3330 EWRAM_DATA struct DodrioBerryPickingStruct * gUnknown_02022C98 = NULL; +EWRAM_DATA u16 * gUnknown_02022C9C[5] = {NULL}; +EWRAM_DATA u16 * gUnknown_02022CB0[2] = {NULL}; +EWRAM_DATA u16 * gUnknown_02022CB8[11] = {NULL}; +EWRAM_DATA u16 * gUnknown_02022CE4[4] = {NULL}; +EWRAM_DATA struct DodrioBerryPickingStruct_2022CF4 * gUnknown_02022CF4 = NULL; +EWRAM_DATA struct DodrioBerryPickingSubstruct_0160 * gUnknown_02022CF8 = NULL; + IWRAM_DATA bool32 gUnknown_03000DB0; void sub_8024A1C(void); @@ -94,6 +114,20 @@ void sub_80261F8(struct DodrioBerryPickingSubstruct_318C *, struct Pokemon *); void sub_80261CC(void); void sub_8026B5C(u8, u8*, u8*); void sub_80273F0(void); +void sub_8029274(struct DodrioBerryPickingSubstruct_0160 *); +void sub_8025910(u8 taskId); +void sub_802620C(TaskFunc, u8); +bool32 sub_802A770(void); +void sub_80283A8(void); +void sub_8028408(struct DodrioBerryPickingSubstruct_318C *, u8, u8, u8); +void sub_802868C(u8, u8); +void sub_8028A34(void); +void sub_8028A88(void); +void sub_8028D44(void); +void sub_8028734(void); +void sub_80261E4(void); +void sub_802621C(TaskFunc); +void sub_802589C(u8 taskId); void sub_802493C(u16 a0, void (*a1)(void)) { @@ -181,3 +215,76 @@ void sub_8024A30(struct DodrioBerryPickingStruct * data) data->unk_0034[i] %= data->unk_0024; } } + +void sub_8024BC8(u8 taskId) +{ + u8 r4, r5; + + switch (gUnknown_02022C98->unk_000C) + { + case 0: + SetVBlankCallback(NULL); + sub_802620C(sub_8025910, 4); + gUnknown_02022C98->unk_000C++; + break; + case 1: + if (!FuncIsActiveTask(sub_8025910)) + { + sub_8029274(&gUnknown_02022C98->unk_0160); + gUnknown_02022C98->unk_000C++; + } + break; + case 2: + if (!sub_802A770()) + { + sub_8010434(); + gUnknown_02022C98->unk_000C++; + } + break; + case 3: + if (IsLinkTaskFinished()) + { + if (gReceivedRemoteLinkPlayers != 0) + { + sub_800E0E8(); + CreateWirelessStatusIndicatorSprite(0, 0); + } + gUnknown_02022C98->unk_000C++; + } + break; + case 4: + r5 = gUnknown_02022C98->unk_0024; + sub_80283A8(); + for (r4 = 0; r4 < r5; r4++) + { + sub_8028408(&gUnknown_02022C98->unk_318C[gUnknown_02022C98->unk_0034[r4]], r4, gUnknown_02022C98->unk_0034[r4], gUnknown_02022C98->unk_0024); + } + sub_802868C(0, gUnknown_02022C98->unk_0024); + gUnknown_02022C98->unk_000C++; + break; + case 5: + sub_8028A34(); + sub_8028A88(); + sub_8028D44(); + sub_8028734(); + gUnknown_02022C98->unk_000C++; + break; + case 6: + BlendPalettes(0xFFFFFFFF, 0x10, 0x00); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); + SetVBlankCallback(sub_80261E4); + gUnknown_02022C98->unk_000C++; + break; + case 7: + UpdatePaletteFade(); + if (!gPaletteFade.active) + { + gUnknown_02022C98->unk_000C++; + } + break; + default: + DestroyTask(taskId); + sub_802621C(sub_802589C); + break; + } +} diff --git a/sym_ewram.txt b/sym_ewram.txt index 937568855..b790c56f4 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -78,24 +78,6 @@ gUnknown_02022C94: @ 2022C94 .include "src/dodrio_berry_picking.o" -gUnknown_02022C9C: @ 2022C9C - .space 0x14 - -gUnknown_02022CB0: @ 2022CB0 - .space 0x8 - -gUnknown_02022CB8: @ 2022CB8 - .space 0x2C - -gUnknown_02022CE4: @ 2022CE4 - .space 0x10 - -gUnknown_02022CF4: @ 2022CF4 - .space 0x4 - -gUnknown_02022CF8: @ 2022CF8 - .space 0x4 - gUnknown_02022CFC: @ 2022CFC .space 0x4 From d49d3b6858b13665840b14dd7d963b72b7e74fb4 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 24 Mar 2019 21:17:25 -0400 Subject: [PATCH 03/13] through sub_8024E38 --- asm/dodrio_berry_picking.s | 208 ------------------------------------- include/pokemon_jump.h | 7 ++ src/dodrio_berry_picking.c | 143 +++++++++++++++++++++++-- 3 files changed, 140 insertions(+), 218 deletions(-) create mode 100644 include/pokemon_jump.h diff --git a/asm/dodrio_berry_picking.s b/asm/dodrio_berry_picking.s index 7155edf1b..225bbad62 100755 --- a/asm/dodrio_berry_picking.s +++ b/asm/dodrio_berry_picking.s @@ -5,214 +5,6 @@ .text - thumb_func_start sub_8024D4C -sub_8024D4C: @ 8024D4C - push {lr} - bl sub_8025D04 - ldr r1, =gUnknown_082F7AC4 - ldr r0, =gUnknown_02022C98 - ldr r0, [r0] - ldrb r0, [r0, 0x18] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - bl _call_via_r0 - ldr r0, =gUnknown_03000DB0 - ldr r0, [r0] - cmp r0, 0 - bne _08024D70 - bl sub_8026AF4 -_08024D70: - bl sub_8025D50 - pop {r0} - bx r0 - .pool - thumb_func_end sub_8024D4C - - thumb_func_start sub_8024D84 -sub_8024D84: @ 8024D84 - push {lr} - bl sub_8025E0C - ldr r1, =gUnknown_082F7AF4 - ldr r0, =gUnknown_02022C98 - ldr r0, [r0] - ldrb r0, [r0, 0x18] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - bl _call_via_r0 - ldr r0, =gUnknown_03000DB0 - ldr r0, [r0] - cmp r0, 0 - bne _08024DA8 - bl sub_8026B28 -_08024DA8: - bl sub_8025ED8 - pop {r0} - bx r0 - .pool - thumb_func_end sub_8024D84 - - thumb_func_start sub_8024DBC -sub_8024DBC: @ 8024DBC - push {r4,lr} - ldr r4, =gUnknown_02022C98 - ldr r0, [r4] - ldrb r0, [r0, 0x10] - cmp r0, 0 - beq _08024DD4 - cmp r0, 0x1 - beq _08024DEA - b _08024DF8 - .pool -_08024DD4: - movs r0, 0x1 - bl sub_8028504 - movs r0, 0x1 - bl sub_80292E0 - ldr r1, [r4] - ldrb r0, [r1, 0x10] - adds r0, 0x1 - strb r0, [r1, 0x10] - b _08024DF8 -_08024DEA: - bl sub_802A770 - cmp r0, 0 - bne _08024DF8 - movs r0, 0x1 - bl sub_8026240 -_08024DF8: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8024DBC - - thumb_func_start sub_8024E00 -sub_8024E00: @ 8024E00 - push {r4,lr} - ldr r4, =gUnknown_02022C98 - ldr r1, [r4] - ldrb r0, [r1, 0x10] - cmp r0, 0 - bne _08024E20 - bl sub_80262C0 - ldr r1, [r4] - ldrb r0, [r1, 0x10] - adds r0, 0x1 - strb r0, [r1, 0x10] - b _08024E30 - .pool -_08024E20: - movs r0, 0x8C - lsls r0, 1 - adds r1, r0 - movs r0, 0x1 - str r0, [r1] - movs r0, 0x2 - bl sub_8026240 -_08024E30: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8024E00 - - thumb_func_start sub_8024E38 -sub_8024E38: @ 8024E38 - push {r4,lr} - sub sp, 0x4 - ldr r1, =gUnknown_02022C98 - ldr r0, [r1] - ldrb r0, [r0, 0x10] - adds r4, r1, 0 - cmp r0, 0x5 - bhi _08024F08 - lsls r0, 2 - ldr r1, =_08024E5C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08024E5C: - .4byte _08024E74 - .4byte _08024E90 - .4byte _08024EA0 - .4byte _08024EC4 - .4byte _08024ED8 - .4byte _08024EF8 -_08024E74: - movs r0, 0 - str r0, [sp] - movs r0, 0x7 - movs r1, 0x8 - movs r2, 0x78 - movs r3, 0x50 - bl sub_802EB24 - ldr r0, =gUnknown_02022C98 - ldr r1, [r0] - b _08024EF0 - .pool -_08024E90: - bl sub_8010434 - ldr r0, =gUnknown_02022C98 - ldr r1, [r0] - b _08024EF0 - .pool -_08024EA0: - bl IsLinkTaskFinished - lsls r0, 24 - cmp r0, 0 - beq _08024F08 - ldr r2, =gUnknown_02022C98 - ldr r1, [r2] - ldrb r0, [r1, 0x10] - adds r0, 0x1 - movs r3, 0 - strb r0, [r1, 0x10] - ldr r0, [r2] - adds r0, 0x30 - strb r3, [r0] - b _08024F08 - .pool -_08024EC4: - bl sub_802EB84 - cmp r0, 0 - bne _08024F08 - ldr r0, =gUnknown_02022C98 - ldr r1, [r0] - b _08024EF0 - .pool -_08024ED8: - ldr r1, [r4] - adds r1, 0x30 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x5 - bls _08024F08 - bl sub_8010434 - ldr r1, [r4] -_08024EF0: - ldrb r0, [r1, 0x10] - adds r0, 0x1 - strb r0, [r1, 0x10] - b _08024F08 -_08024EF8: - bl IsLinkTaskFinished - lsls r0, 24 - cmp r0, 0 - beq _08024F08 - movs r0, 0x3 - bl sub_8026240 -_08024F08: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8024E38 - thumb_func_start sub_8024F10 sub_8024F10: @ 8024F10 push {lr} diff --git a/include/pokemon_jump.h b/include/pokemon_jump.h new file mode 100644 index 000000000..f54e0d460 --- /dev/null +++ b/include/pokemon_jump.h @@ -0,0 +1,7 @@ +#ifndef GUARD_POKEMON_JUMP_H +#define GUARD_POKEMON_JUMP_H + +void sub_802EB24(u8, u8, u8, u8, u8); +bool32 sub_802EB84(void); + +#endif //GUARD_POKEMON_JUMP_H diff --git a/src/dodrio_berry_picking.c b/src/dodrio_berry_picking.c index eef4ec262..bc461b0d8 100644 --- a/src/dodrio_berry_picking.c +++ b/src/dodrio_berry_picking.c @@ -7,6 +7,7 @@ #include "main.h" #include "constants/songs.h" #include "sound.h" +#include "pokemon_jump.h" struct DodrioBerryPickingSubstruct_0160 { @@ -83,7 +84,8 @@ struct DodrioBerryPickingStruct /*0x00F4*/ u8 unk_00F4[11][2]; /*0x010A*/ u8 filler_010A[2]; /*0x010C*/ u8 unk_010C[5]; - /*0x0111*/ u8 filler_0111[11]; + /*0x0111*/ u8 filler_0111[7]; + /*0x0118*/ u32 unk_0118; /*0x011C*/ u32 unk_011C; /*0x0120*/ u32 unk_0120; /*0x0124*/ u8 filler_0124[8]; @@ -110,24 +112,52 @@ IWRAM_DATA bool32 gUnknown_03000DB0; void sub_8024A1C(void); void sub_8024A30(struct DodrioBerryPickingStruct *); void sub_8024BC8(u8 taskId); -void sub_80261F8(struct DodrioBerryPickingSubstruct_318C *, struct Pokemon *); +void sub_8024DBC(void); +void sub_8024E00(void); +void sub_8024E38(void); +void sub_8024F10(void); +void sub_8024F38(void); +void sub_8024FFC(void); +void sub_80250D4(void); +void sub_8025198(void); +void sub_8025230(void); +void sub_8025324(void); +void sub_8025470(void); +void sub_8025644(void); +void sub_80256AC(void); +void sub_8025758(void); +void sub_8025158(void); +void sub_802589C(u8 taskId); +void sub_8025910(u8 taskId); +void sub_8025D04(void); +void sub_8025D50(void); +void sub_8025E0C(void); +void sub_8025ED8(void); void sub_80261CC(void); +void sub_80261E4(void); +void sub_80261F8(struct DodrioBerryPickingSubstruct_318C *, struct Pokemon *); +void sub_802620C(TaskFunc, u8); +void sub_802621C(TaskFunc); +void sub_8026240(u8); +void sub_80262C0(void); +void sub_8026AF4(void); +void sub_8026B28(void); void sub_8026B5C(u8, u8*, u8*); void sub_80273F0(void); -void sub_8029274(struct DodrioBerryPickingSubstruct_0160 *); -void sub_8025910(u8 taskId); -void sub_802620C(TaskFunc, u8); -bool32 sub_802A770(void); void sub_80283A8(void); void sub_8028408(struct DodrioBerryPickingSubstruct_318C *, u8, u8, u8); +void sub_8028504(u8); void sub_802868C(u8, u8); +void sub_8028734(void); void sub_8028A34(void); void sub_8028A88(void); void sub_8028D44(void); -void sub_8028734(void); -void sub_80261E4(void); -void sub_802621C(TaskFunc); -void sub_802589C(u8 taskId); +void sub_8029274(struct DodrioBerryPickingSubstruct_0160 *); +void sub_80292E0(u8); +bool32 sub_802A770(void); + +extern void (*const gUnknown_082F7AC4[])(void); +extern void (*const gUnknown_082F7AF4[])(void); void sub_802493C(u16 a0, void (*a1)(void)) { @@ -288,3 +318,96 @@ void sub_8024BC8(u8 taskId) break; } } + +void sub_8024D4C(void) +{ + sub_8025D04(); + gUnknown_082F7AC4[gUnknown_02022C98->unk_0018](); + if (gUnknown_03000DB0 == FALSE) + { + sub_8026AF4(); + } + sub_8025D50(); +} + +void sub_8024D84(void) +{ + sub_8025E0C(); + gUnknown_082F7AF4[gUnknown_02022C98->unk_0018](); + if (gUnknown_03000DB0 == FALSE) + { + sub_8026B28(); + } + sub_8025ED8(); +} + +void sub_8024DBC(void) +{ + switch (gUnknown_02022C98->unk_0010) + { + case 0: + sub_8028504(1); + sub_80292E0(1); + gUnknown_02022C98->unk_0010++; + break; + case 1: + if (!sub_802A770()) + sub_8026240(1); + break; + } +} + +void sub_8024E00(void) +{ + if (gUnknown_02022C98->unk_0010 == 0) + { + sub_80262C0(); + gUnknown_02022C98->unk_0010++; + } + else + { + gUnknown_02022C98->unk_0118 = 1; + sub_8026240(2); + } +} + +void sub_8024E38(void) +{ + switch (gUnknown_02022C98->unk_0010) + { + case 0: + sub_802EB24(7, 8, 120, 80, 0); + gUnknown_02022C98->unk_0010++; + break; + case 1: + sub_8010434(); + gUnknown_02022C98->unk_0010++; + break; + case 2: + if (IsLinkTaskFinished()) + { + gUnknown_02022C98->unk_0010++; + gUnknown_02022C98->unk_0030 = 0; + } + break; + case 3: + if (!sub_802EB84()) + { + gUnknown_02022C98->unk_0010++; + } + break; + case 4: + if (++gUnknown_02022C98->unk_0030 > 5) + { + sub_8010434(); + gUnknown_02022C98->unk_0010++; + } + break; + case 5: + if (IsLinkTaskFinished()) + { + sub_8026240(3); + } + break; + } +} From d4cca4ffa2fe1fbeacc3eeb961112a7c71d37f47 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 24 Mar 2019 22:56:16 -0400 Subject: [PATCH 04/13] through sub_8024F38 --- asm/dodrio_berry_picking.s | 116 ------------------------------------- include/global.h | 5 ++ src/dodrio_berry_picking.c | 69 +++++++++++++++++++++- 3 files changed, 72 insertions(+), 118 deletions(-) diff --git a/asm/dodrio_berry_picking.s b/asm/dodrio_berry_picking.s index 225bbad62..a36bdf11f 100755 --- a/asm/dodrio_berry_picking.s +++ b/asm/dodrio_berry_picking.s @@ -5,122 +5,6 @@ .text - thumb_func_start sub_8024F10 -sub_8024F10: @ 8024F10 - push {lr} - ldr r0, =gUnknown_02022C98 - ldr r1, [r0] - ldrb r0, [r1, 0x10] - cmp r0, 0 - bne _08024F2E - movs r2, 0x8E - lsls r2, 1 - adds r0, r1, r2 - ldr r0, [r0] - cmp r0, 0 - beq _08024F2E - movs r0, 0x4 - bl sub_8026240 -_08024F2E: - pop {r0} - bx r0 - .pool - thumb_func_end sub_8024F10 - - thumb_func_start sub_8024F38 -sub_8024F38: @ 8024F38 - push {r4,lr} - ldr r4, =gUnknown_02022C98 - ldr r2, [r4] - ldrb r0, [r2, 0x10] - cmp r0, 0 - bne _08024FF6 - adds r0, r2, 0 - adds r0, 0x40 - ldrb r0, [r0] - cmp r0, 0x9 - bhi _08024FE8 - adds r0, r2, 0 - adds r0, 0xA8 - ldrb r0, [r0] - cmp r0, 0 - bne _08024FEE - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _08024F88 - ldr r1, =0x000031cc - adds r0, r2, r1 - ldrb r1, [r0] - cmp r1, 0 - bne _08024FEE - ldr r3, =0x000031d0 - adds r0, r2, r3 - strb r1, [r0] - movs r0, 0x2 - b _08024FC2 - .pool -_08024F88: - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _08024FA8 - ldr r3, =0x000031cc - adds r0, r2, r3 - ldrb r1, [r0] - cmp r1, 0 - bne _08024FEE - adds r3, 0x4 - adds r0, r2, r3 - strb r1, [r0] - movs r0, 0x1 - b _08024FC2 - .pool -_08024FA8: - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _08024FD4 - ldr r3, =0x000031cc - adds r0, r2, r3 - ldrb r1, [r0] - cmp r1, 0 - bne _08024FEE - adds r3, 0x4 - adds r0, r2, r3 - strb r1, [r0] - movs r0, 0x3 -_08024FC2: - bl sub_8027518 - ldr r1, [r4] - ldr r2, =0x000031cc - adds r1, r2 - strb r0, [r1] - b _08024FEE - .pool -_08024FD4: - movs r0, 0 - bl sub_8027518 - ldr r1, [r4] - ldr r3, =0x000031cc - adds r1, r3 - strb r0, [r1] - b _08024FEE - .pool -_08024FE8: - movs r0, 0xB - bl sub_8026240 -_08024FEE: - bl sub_802671C - bl sub_8025F48 -_08024FF6: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8024F38 - thumb_func_start sub_8024FFC sub_8024FFC: @ 8024FFC push {lr} diff --git a/include/global.h b/include/global.h index d738deb3c..778019812 100644 --- a/include/global.h +++ b/include/global.h @@ -86,6 +86,11 @@ #define T2_READ_32(ptr) ((ptr)[0] + ((ptr)[1] << 8) + ((ptr)[2] << 16) + ((ptr)[3] << 24)) #define T2_READ_PTR(ptr) (void*) T2_READ_32(ptr) +// Macros for checking the joypad +#define TEST_BUTTON(field, button) ({(field) & (button);}) +#define JOY_NEW(button) TEST_BUTTON(gMain.newKeys, button) +#define JOY_HELD(button) TEST_BUTTON(gMain.heldKeys, button) + #define S16TOPOSFLOAT(val) \ ({ \ s16 v = (val); \ diff --git a/src/dodrio_berry_picking.c b/src/dodrio_berry_picking.c index bc461b0d8..0ea07e677 100644 --- a/src/dodrio_berry_picking.c +++ b/src/dodrio_berry_picking.c @@ -27,7 +27,11 @@ struct DodrioBerryPickingStruct_2022CF4 struct DodrioBerryPickingSubstruct_31A0 { - u8 unk_00[0x3C - 0x00]; + u8 unk_00[0x2C - 0x00]; + u8 unk_2C; + u8 filler_2D[3]; + u8 unk_30; + u8 filler_31[11]; }; // size = 0x3C struct DodrioBerryPickingSubstruct_318C @@ -119,6 +123,7 @@ void sub_8024F10(void); void sub_8024F38(void); void sub_8024FFC(void); void sub_80250D4(void); +void sub_8025158(void); void sub_8025198(void); void sub_8025230(void); void sub_8025324(void); @@ -126,13 +131,13 @@ void sub_8025470(void); void sub_8025644(void); void sub_80256AC(void); void sub_8025758(void); -void sub_8025158(void); void sub_802589C(u8 taskId); void sub_8025910(u8 taskId); void sub_8025D04(void); void sub_8025D50(void); void sub_8025E0C(void); void sub_8025ED8(void); +void sub_8025F48(void); void sub_80261CC(void); void sub_80261E4(void); void sub_80261F8(struct DodrioBerryPickingSubstruct_318C *, struct Pokemon *); @@ -140,10 +145,12 @@ void sub_802620C(TaskFunc, u8); void sub_802621C(TaskFunc); void sub_8026240(u8); void sub_80262C0(void); +void sub_802671C(void); void sub_8026AF4(void); void sub_8026B28(void); void sub_8026B5C(u8, u8*, u8*); void sub_80273F0(void); +u8 sub_8027518(u8); void sub_80283A8(void); void sub_8028408(struct DodrioBerryPickingSubstruct_318C *, u8, u8, u8); void sub_8028504(u8); @@ -411,3 +418,61 @@ void sub_8024E38(void) break; } } + +void sub_8024F10(void) +{ + if (gUnknown_02022C98->unk_0010 == 0) + { + if (gUnknown_02022C98->unk_011C != 0) + { + sub_8026240(4); + } + } +} + +void sub_8024F38(void) +{ + if (gUnknown_02022C98->unk_0010 == 0) + { + if (gUnknown_02022C98->unk_0040 < 10) + { + if (gUnknown_02022C98->unk_00A8[0] == 0) + { + if (JOY_NEW(DPAD_UP)) + { + if (gUnknown_02022C98->unk_31A0[0].unk_2C == 0) + { + gUnknown_02022C98->unk_31A0[0].unk_30 = 0; + gUnknown_02022C98->unk_31A0[0].unk_2C = sub_8027518(2); + } + } + else if (JOY_NEW(DPAD_RIGHT)) + { + if (gUnknown_02022C98->unk_31A0[0].unk_2C == 0) + { + gUnknown_02022C98->unk_31A0[0].unk_30 = 0; + gUnknown_02022C98->unk_31A0[0].unk_2C = sub_8027518(1); + } + } + else if (JOY_NEW(DPAD_LEFT)) + { + if (gUnknown_02022C98->unk_31A0[0].unk_2C == 0) + { + gUnknown_02022C98->unk_31A0[0].unk_30 = 0; + gUnknown_02022C98->unk_31A0[0].unk_2C = sub_8027518(3); + } + } + else + { + gUnknown_02022C98->unk_31A0[0].unk_2C = sub_8027518(0); + } + } + } + else + { + sub_8026240(11); + } + sub_802671C(); + sub_8025F48(); + } +} From c005c2f7371bfd23f8e4c72bfcccf721dc33249b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 25 Mar 2019 08:31:29 -0400 Subject: [PATCH 05/13] sub_8024FFC --- asm/dodrio_berry_picking.s | 97 -------------------------------------- src/dodrio_berry_picking.c | 38 +++++++++++++++ 2 files changed, 38 insertions(+), 97 deletions(-) diff --git a/asm/dodrio_berry_picking.s b/asm/dodrio_berry_picking.s index a36bdf11f..624bc3dbe 100755 --- a/asm/dodrio_berry_picking.s +++ b/asm/dodrio_berry_picking.s @@ -5,103 +5,6 @@ .text - thumb_func_start sub_8024FFC -sub_8024FFC: @ 8024FFC - push {lr} - ldr r0, =gUnknown_02022C98 - ldr r2, [r0] - adds r0, r2, 0 - adds r0, 0x40 - ldrb r0, [r0] - cmp r0, 0x9 - bhi _080250C4 - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _0802504C - adds r0, r2, 0 - adds r0, 0x28 - ldrb r1, [r0] - lsls r0, r1, 4 - subs r0, r1 - lsls r0, 2 - adds r0, r2, r0 - ldr r1, =0x000031cc - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - bne _080250CA - ldr r3, =0x000032f8 - adds r1, r2, r3 - movs r0, 0x2 - strb r0, [r1] - b _080250CA - .pool -_0802504C: - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _08025080 - adds r0, r2, 0 - adds r0, 0x28 - ldrb r1, [r0] - lsls r0, r1, 4 - subs r0, r1 - lsls r0, 2 - adds r0, r2, r0 - ldr r1, =0x000031cc - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - bne _080250CA - ldr r3, =0x000032f8 - adds r1, r2, r3 - movs r0, 0x1 - strb r0, [r1] - b _080250CA - .pool -_08025080: - movs r0, 0x20 - ands r0, r1 - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0 - beq _080250B8 - adds r0, r2, 0 - adds r0, 0x28 - ldrb r1, [r0] - lsls r0, r1, 4 - subs r0, r1 - lsls r0, 2 - adds r0, r2, r0 - ldr r1, =0x000031cc - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - bne _080250CA - ldr r3, =0x000032f8 - adds r1, r2, r3 - movs r0, 0x3 - strb r0, [r1] - b _080250CA - .pool -_080250B8: - ldr r3, =0x000032f8 - adds r0, r2, r3 - strb r1, [r0] - b _080250CA - .pool -_080250C4: - movs r0, 0xB - bl sub_8026240 -_080250CA: - bl sub_8026044 - pop {r0} - bx r0 - thumb_func_end sub_8024FFC - thumb_func_start sub_80250D4 sub_80250D4: @ 80250D4 push {r4,r5,lr} diff --git a/src/dodrio_berry_picking.c b/src/dodrio_berry_picking.c index 0ea07e677..bd6b88877 100644 --- a/src/dodrio_berry_picking.c +++ b/src/dodrio_berry_picking.c @@ -138,6 +138,7 @@ void sub_8025D50(void); void sub_8025E0C(void); void sub_8025ED8(void); void sub_8025F48(void); +void sub_8026044(void); void sub_80261CC(void); void sub_80261E4(void); void sub_80261F8(struct DodrioBerryPickingSubstruct_318C *, struct Pokemon *); @@ -476,3 +477,40 @@ void sub_8024F38(void) sub_8025F48(); } } + +void sub_8024FFC(void) +{ + if (gUnknown_02022C98->unk_0040 < 10) + { + if (JOY_NEW(DPAD_UP)) + { + if (gUnknown_02022C98->unk_31A0[gUnknown_02022C98->multiplayerId].unk_2C == 0) + { + gUnknown_02022C98->unk_32CC.unk_2C = 2; + } + } + else if (JOY_NEW(DPAD_RIGHT)) + { + if (gUnknown_02022C98->unk_31A0[gUnknown_02022C98->multiplayerId].unk_2C == 0) + { + gUnknown_02022C98->unk_32CC.unk_2C = 1; + } + } + else if (JOY_NEW(DPAD_LEFT)) + { + if (gUnknown_02022C98->unk_31A0[gUnknown_02022C98->multiplayerId].unk_2C == 0) + { + gUnknown_02022C98->unk_32CC.unk_2C = 3; + } + } + else + { + gUnknown_02022C98->unk_32CC.unk_2C = 0; + } + } + else + { + sub_8026240(11); + } + sub_8026044(); +} From 4780f208d3ed3c0e4077f067631aa9e76041b26b Mon Sep 17 00:00:00 2001 From: scnorton Date: Mon, 25 Mar 2019 11:22:48 -0400 Subject: [PATCH 06/13] through sub_8025324 --- asm/dodrio_berry_picking.s | 456 ------------------------------------- src/dodrio_berry_picking.c | 202 +++++++++++++++- 2 files changed, 200 insertions(+), 458 deletions(-) diff --git a/asm/dodrio_berry_picking.s b/asm/dodrio_berry_picking.s index 624bc3dbe..7441c2593 100755 --- a/asm/dodrio_berry_picking.s +++ b/asm/dodrio_berry_picking.s @@ -5,462 +5,6 @@ .text - thumb_func_start sub_80250D4 -sub_80250D4: @ 80250D4 - push {r4,r5,lr} - bl sub_802671C - bl sub_8025F48 - bl sub_8026C50 - cmp r0, 0x1 - bne _080250F2 - bl sub_80272A4 - movs r0, 0x5 - bl sub_8026240 - b _08025150 -_080250F2: - ldr r0, =gUnknown_02022C98 - ldr r2, [r0] - movs r1, 0x96 - lsls r1, 1 - adds r4, r2, r1 - movs r1, 0x1 - str r1, [r4] - movs r3, 0x1 - adds r1, r2, 0 - adds r1, 0x24 - adds r5, r0, 0 - ldrb r1, [r1] - cmp r3, r1 - bcs _08025150 - movs r1, 0x9A - lsls r1, 1 - adds r0, r2, r1 - ldr r0, [r0] - cmp r0, 0x1 - beq _08025124 - movs r0, 0 - str r0, [r4] - b _08025150 - .pool -_08025124: - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - ldr r2, [r5] - adds r0, r2, 0 - adds r0, 0x24 - ldrb r0, [r0] - cmp r3, r0 - bcs _08025150 - lsls r0, r3, 2 - movs r4, 0x98 - lsls r4, 1 - adds r1, r2, r4 - adds r1, r0 - ldr r0, [r1] - cmp r0, 0x1 - beq _08025124 - movs r0, 0x96 - lsls r0, 1 - adds r1, r2, r0 - movs r0, 0 - str r0, [r1] -_08025150: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_80250D4 - - thumb_func_start sub_8025158 -sub_8025158: @ 8025158 - push {lr} - bl sub_8026044 - bl sub_8026C90 - cmp r0, 0x1 - bne _0802516C - movs r0, 0x5 - bl sub_8026240 -_0802516C: - pop {r0} - bx r0 - thumb_func_end sub_8025158 - - thumb_func_start sub_8025170 -sub_8025170: @ 8025170 - push {r4,lr} - bl GetBlockReceivedStatus - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - bl sub_800A9D8 - lsls r0, 24 - lsrs r0, 24 - cmp r4, r0 - beq _0802518C - movs r0, 0 - b _08025192 -_0802518C: - bl ResetBlockReceivedFlags - movs r0, 0x1 -_08025192: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8025170 - - thumb_func_start sub_8025198 -sub_8025198: @ 8025198 - push {r4,r5,lr} - ldr r5, =gUnknown_02022C98 - ldr r1, [r5] - ldrb r4, [r1, 0x10] - cmp r4, 0x1 - beq _080251D0 - cmp r4, 0x1 - bgt _080251B4 - cmp r4, 0 - beq _080251BA - b _0802520C - .pool -_080251B4: - cmp r4, 0x2 - beq _080251DC - b _0802520C -_080251BA: - adds r1, 0x4A - movs r0, 0 - movs r2, 0x3C - bl SendBlock - lsls r0, 24 - cmp r0, 0 - beq _08025226 - ldr r0, [r5] - strb r4, [r0, 0x8] - b _08025202 -_080251D0: - bl IsLinkTaskFinished - lsls r0, 24 - cmp r0, 0 - beq _08025226 - b _08025202 -_080251DC: - bl sub_8025170 - cmp r0, 0 - beq _080251EE - ldr r0, [r5] - adds r1, r0, 0 - adds r1, 0x24 - ldrb r1, [r1] - strb r1, [r0, 0x8] -_080251EE: - ldr r2, [r5] - adds r1, r2, 0 - adds r1, 0x24 - ldrb r0, [r2, 0x8] - ldrb r1, [r1] - cmp r0, r1 - bcc _08025226 - ldrb r0, [r2, 0x14] - adds r0, 0x1 - strb r0, [r2, 0x14] -_08025202: - ldr r1, [r5] - ldrb r0, [r1, 0x10] - adds r0, 0x1 - strb r0, [r1, 0x10] - b _08025226 -_0802520C: - movs r0, 0x1 - bl WaitFanfare - lsls r0, 24 - cmp r0, 0 - beq _08025226 - movs r0, 0x6 - bl sub_8026240 - ldr r0, =0x0000020b - movs r1, 0x4 - bl FadeOutAndPlayNewMapMusic -_08025226: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8025198 - - thumb_func_start sub_8025230 -sub_8025230: @ 8025230 - push {r4,r5,lr} - ldr r5, =gUnknown_02022C98 - ldr r2, [r5] - ldrb r4, [r2, 0x10] - cmp r4, 0x1 - beq _08025274 - cmp r4, 0x1 - bgt _0802524C - cmp r4, 0 - beq _08025252 - b _080252DC - .pool -_0802524C: - cmp r4, 0x2 - beq _08025282 - b _080252DC -_08025252: - ldrb r0, [r2, 0x14] - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 2 - adds r1, 0x4A - adds r1, r2, r1 - movs r0, 0 - movs r2, 0x3C - bl SendBlock - lsls r0, 24 - cmp r0, 0 - beq _08025316 - ldr r0, [r5] - strb r4, [r0, 0x8] - ldr r1, [r5] - b _080252CC -_08025274: - bl IsLinkTaskFinished - lsls r0, 24 - cmp r0, 0 - beq _08025316 - ldr r1, [r5] - b _080252CC -_08025282: - bl sub_8025170 - cmp r0, 0 - beq _080252B4 - movs r4, 0 - b _080252AA -_0802528E: - ldr r0, [r5] - adds r0, 0x4A - ldr r1, =gBlockRecvBuffer - movs r2, 0x3C - bl memcpy - ldr r1, [r5] - adds r0, r1, 0 - adds r0, 0x24 - ldrb r0, [r0] - strb r0, [r1, 0x8] - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 -_080252AA: - ldr r0, [r5] - adds r0, 0x24 - ldrb r0, [r0] - cmp r4, r0 - bcc _0802528E -_080252B4: - ldr r3, =gUnknown_02022C98 - ldr r2, [r3] - adds r1, r2, 0 - adds r1, 0x24 - ldrb r0, [r2, 0x8] - ldrb r1, [r1] - cmp r0, r1 - bcc _08025316 - ldrb r0, [r2, 0x14] - adds r0, 0x1 - strb r0, [r2, 0x14] - ldr r1, [r3] -_080252CC: - ldrb r0, [r1, 0x10] - adds r0, 0x1 - strb r0, [r1, 0x10] - b _08025316 - .pool -_080252DC: - movs r0, 0x1 - bl WaitFanfare - lsls r0, 24 - cmp r0, 0 - beq _08025316 - ldr r0, =gUnknown_02022C98 - ldr r2, [r0] - adds r0, r2, 0 - adds r0, 0x28 - ldrb r0, [r0] - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 2 - adds r0, r2, 0 - adds r0, 0x54 - adds r0, r1 - ldrh r1, [r0] - movs r3, 0x8A - lsls r3, 1 - adds r0, r2, r3 - strh r1, [r0] - movs r0, 0x6 - bl sub_8026240 - ldr r0, =0x0000020b - movs r1, 0x4 - bl FadeOutAndPlayNewMapMusic -_08025316: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8025230 - - thumb_func_start sub_8025324 -sub_8025324: @ 8025324 - push {r4,r5,lr} - sub sp, 0x4 - movs r1, 0x1 - mov r0, sp - strb r1, [r0] - ldr r0, =gUnknown_02022C98 - ldr r0, [r0] - ldrb r0, [r0, 0x10] - cmp r0, 0x4 - bls _0802533A - b _08025458 -_0802533A: - lsls r0, 2 - ldr r1, =_0802534C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0802534C: - .4byte _08025360 - .4byte _08025384 - .4byte _0802539C - .4byte _080253BC - .4byte _080253DC -_08025360: - bl sub_802749C - movs r0, 0x1 - bl sub_80289E8 - bl sub_8028DFC - movs r0, 0x1 - bl sub_8028EC8 - movs r0, 0x2 - bl sub_80292E0 - ldr r0, =gUnknown_02022C98 - ldr r1, [r0] - b _08025448 - .pool -_08025384: - bl sub_802A770 - cmp r0, 0 - bne _08025466 - movs r0, 0x5 - bl sub_80292E0 - ldr r0, =gUnknown_02022C98 - ldr r1, [r0] - b _08025448 - .pool -_0802539C: - bl sub_802A794 - mov r1, sp - strb r0, [r1] - movs r0, 0 - movs r2, 0x1 - bl SendBlock - lsls r0, 24 - cmp r0, 0 - beq _08025466 - ldr r0, =gUnknown_02022C98 - ldr r1, [r0] - b _08025448 - .pool -_080253BC: - bl IsLinkTaskFinished - lsls r0, 24 - cmp r0, 0 - beq _08025466 - ldr r3, =gUnknown_02022C98 - ldr r1, [r3] - ldrb r0, [r1, 0x10] - adds r0, 0x1 - movs r2, 0 - strb r0, [r1, 0x10] - ldr r0, [r3] - strb r2, [r0, 0x8] - b _08025466 - .pool -_080253DC: - bl sub_8025170 - cmp r0, 0 - beq _08025422 - movs r2, 0 - ldr r1, =gUnknown_02022C98 - ldr r0, [r1] - adds r0, 0x24 - ldrb r0, [r0] - cmp r2, r0 - bcs _08025422 - adds r3, r1, 0 - movs r5, 0x86 - lsls r5, 1 - ldr r4, =gBlockRecvBuffer -_080253FA: - ldr r1, [r3] - adds r1, r2, r1 - adds r1, r5 - lsls r0, r2, 8 - adds r0, r4 - ldrb r0, [r0] - strb r0, [r1] - ldr r1, [r3] - adds r0, r1, 0 - adds r0, 0x24 - ldrb r0, [r0] - strb r0, [r1, 0x8] - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - ldr r0, [r3] - adds r0, 0x24 - ldrb r0, [r0] - cmp r2, r0 - bcc _080253FA -_08025422: - ldr r4, =gUnknown_02022C98 - ldr r2, [r4] - adds r1, r2, 0 - adds r1, 0x24 - ldrb r0, [r2, 0x8] - ldrb r1, [r1] - cmp r0, r1 - bcc _08025466 - ldrb r0, [r2, 0x14] - adds r0, 0x1 - strb r0, [r2, 0x14] - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x77 - bls _08025466 - movs r0, 0x6 - bl sub_80292E0 - ldr r1, [r4] -_08025448: - ldrb r0, [r1, 0x10] - adds r0, 0x1 - strb r0, [r1, 0x10] - b _08025466 - .pool -_08025458: - bl sub_802A770 - cmp r0, 0 - bne _08025466 - movs r0, 0x7 - bl sub_8026240 -_08025466: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_8025324 - thumb_func_start sub_8025470 sub_8025470: @ 8025470 push {r4,r5,lr} diff --git a/src/dodrio_berry_picking.c b/src/dodrio_berry_picking.c index bd6b88877..b2fa006a2 100644 --- a/src/dodrio_berry_picking.c +++ b/src/dodrio_berry_picking.c @@ -42,7 +42,9 @@ struct DodrioBerryPickingSubstruct_318C struct DodrioBerryPickingStruct { /*0x0000*/ void (*savedCallback)(void); - /*0x0004*/ u8 filler_0004[8]; + /*0x0004*/ u8 filler_0004[4]; + /*0x0008*/ u8 unk_0008; + /*0x0009*/ u8 filler_0009[3]; /*0x000C*/ u8 unk_000C; /*0x000D*/ u8 filler_000D[3]; /*0x0010*/ u8 unk_0010; @@ -88,7 +90,9 @@ struct DodrioBerryPickingStruct /*0x00F4*/ u8 unk_00F4[11][2]; /*0x010A*/ u8 filler_010A[2]; /*0x010C*/ u8 unk_010C[5]; - /*0x0111*/ u8 filler_0111[7]; + /*0x0111*/ u8 filler_0111[3]; + /*0x0114*/ u16 unk_0114; + // align 2 /*0x0118*/ u32 unk_0118; /*0x011C*/ u32 unk_011C; /*0x0120*/ u32 unk_0120; @@ -150,19 +154,27 @@ void sub_802671C(void); void sub_8026AF4(void); void sub_8026B28(void); void sub_8026B5C(u8, u8*, u8*); +bool32 sub_8026C50(void); +bool32 sub_8026C90(void); +void sub_80272A4(void); void sub_80273F0(void); +void sub_802749C(void); u8 sub_8027518(u8); void sub_80283A8(void); void sub_8028408(struct DodrioBerryPickingSubstruct_318C *, u8, u8, u8); void sub_8028504(u8); void sub_802868C(u8, u8); void sub_8028734(void); +void sub_80289E8(u8); void sub_8028A34(void); void sub_8028A88(void); void sub_8028D44(void); +void sub_8028DFC(void); +void sub_8028EC8(u8); void sub_8029274(struct DodrioBerryPickingSubstruct_0160 *); void sub_80292E0(u8); bool32 sub_802A770(void); +u8 sub_802A794(void); extern void (*const gUnknown_082F7AC4[])(void); extern void (*const gUnknown_082F7AF4[])(void); @@ -514,3 +526,189 @@ void sub_8024FFC(void) } sub_8026044(); } + +void sub_80250D4(void) +{ + u8 i; + + sub_802671C(); + sub_8025F48(); + if (sub_8026C50() == 1) + { + sub_80272A4(); + sub_8026240(5); + } + else + { + gUnknown_02022C98->unk_012C = 1; + for (i = 1; i < gUnknown_02022C98->unk_0024; i++) + { + if (gUnknown_02022C98->unk_0130[i] != 1) + { + gUnknown_02022C98->unk_012C = 0; + break; + } + } + } +} + +void sub_8025158(void) +{ + sub_8026044(); + if (sub_8026C90() == 1) + sub_8026240(5); +} + +bool32 sub_8025170(void) +{ + u8 r4 = GetBlockReceivedStatus(); + u8 r0 = sub_800A9D8(); + if (r4 == r0) + { + ResetBlockReceivedFlags(); + return TRUE; + } + else + { + return FALSE; + } +} + +void sub_8025198(void) +{ + switch (gUnknown_02022C98->unk_0010) + { + case 0: + if (SendBlock(0, gUnknown_02022C98->unk_004A, sizeof(gUnknown_02022C98->unk_004A))) + { + gUnknown_02022C98->unk_0008 = 0; + gUnknown_02022C98->unk_0010++; + } + break; + case 1: + if (IsLinkTaskFinished()) + { + gUnknown_02022C98->unk_0010++; + } + break; + case 2: + if (sub_8025170()) + { + gUnknown_02022C98->unk_0008 = gUnknown_02022C98->unk_0024; + } + if (gUnknown_02022C98->unk_0008 >= gUnknown_02022C98->unk_0024) + { + gUnknown_02022C98->unk_0014++; + gUnknown_02022C98->unk_0010++; + } + break; + default: + if (WaitFanfare(TRUE)) + { + sub_8026240(6); + FadeOutAndPlayNewMapMusic(MUS_RG_WIN_YASEI, 4); + } + break; + } +} + +void sub_8025230(void) +{ + u8 i; + + switch (gUnknown_02022C98->unk_0010) { + case 0: + if (SendBlock(0, gUnknown_02022C98->unk_004A[gUnknown_02022C98->unk_0014], + sizeof(gUnknown_02022C98->unk_004A))) { + gUnknown_02022C98->unk_0008 = 0; + gUnknown_02022C98->unk_0010++; + } + break; + case 1: + if (IsLinkTaskFinished()) { + gUnknown_02022C98->unk_0010++; + } + break; + case 2: + if (sub_8025170()) { + for (i = 0; i < gUnknown_02022C98->unk_0024; i++) { + memcpy(gUnknown_02022C98->unk_004A, gBlockRecvBuffer, sizeof(gUnknown_02022C98->unk_004A)); + gUnknown_02022C98->unk_0008 = gUnknown_02022C98->unk_0024; + } + } + if (gUnknown_02022C98->unk_0008 >= gUnknown_02022C98->unk_0024) { + gUnknown_02022C98->unk_0014++; + gUnknown_02022C98->unk_0010++; + } + break; + default: + if (WaitFanfare(TRUE)) { + gUnknown_02022C98->unk_0114 = gUnknown_02022C98->unk_004A[gUnknown_02022C98->multiplayerId][5]; + sub_8026240(6); + FadeOutAndPlayNewMapMusic(MUS_RG_WIN_YASEI, 4); + } + break; + } +} + +void sub_8025324(void) +{ + u8 sp00 = 1; + u8 i; + + switch (gUnknown_02022C98->unk_0010) + { + case 0: + sub_802749C(); + sub_80289E8(1); + sub_8028DFC(); + sub_8028EC8(1); + sub_80292E0(2); + gUnknown_02022C98->unk_0010++; + break; + case 1: + if (!sub_802A770()) + { + sub_80292E0(5); + gUnknown_02022C98->unk_0010++; + } + break; + case 2: + sp00 = sub_802A794(); + if (SendBlock(0, &sp00, sizeof(sp00))) + { + gUnknown_02022C98->unk_0010++; + } + break; + case 3: + if (IsLinkTaskFinished()) + { + gUnknown_02022C98->unk_0010++; + gUnknown_02022C98->unk_0008 = 0; + } + break; + case 4: + if (sub_8025170()) + { + for (i = 0; i < gUnknown_02022C98->unk_0024; i++) + { + *(gUnknown_02022C98->unk_010C + i) = *(u8 *)gBlockRecvBuffer[i]; + gUnknown_02022C98->unk_0008 = gUnknown_02022C98->unk_0024; + } + } + if (gUnknown_02022C98->unk_0008 >= gUnknown_02022C98->unk_0024) { + if (++gUnknown_02022C98->unk_0014 >= 120) + { + sub_80292E0(6); + gUnknown_02022C98->unk_0010++; + } + } + break; + default: + if (!sub_802A770()) + { + sub_8026240(7); + } + break; + } +} From c3e26a58dfd3cc4236f2658196f5d24cfaf35736 Mon Sep 17 00:00:00 2001 From: scnorton Date: Mon, 25 Mar 2019 12:08:56 -0400 Subject: [PATCH 07/13] through sub_8025758 --- asm/dodrio_berry_picking.s | 487 ------------------------------------- src/dodrio_berry_picking.c | 237 +++++++++++++++++- 2 files changed, 236 insertions(+), 488 deletions(-) diff --git a/asm/dodrio_berry_picking.s b/asm/dodrio_berry_picking.s index 7441c2593..9b7172029 100755 --- a/asm/dodrio_berry_picking.s +++ b/asm/dodrio_berry_picking.s @@ -5,493 +5,6 @@ .text - thumb_func_start sub_8025470 -sub_8025470: @ 8025470 - push {r4,r5,lr} - sub sp, 0x4 - ldr r4, =gUnknown_02022C98 - ldr r0, [r4] - ldrb r0, [r0, 0x10] - cmp r0, 0x7 - bls _08025480 - b _08025606 -_08025480: - lsls r0, 2 - ldr r1, =_08025494 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08025494: - .4byte _080254B4 - .4byte _080254D4 - .4byte _080254F0 - .4byte _08025504 - .4byte _08025520 - .4byte _0802553C - .4byte _08025564 - .4byte _08025578 -_080254B4: - bl sub_8027748 - ldr r1, =0x00000bb7 - cmp r0, r1 - bls _080254C4 - movs r0, 0x4 - bl sub_80292E0 -_080254C4: - ldr r0, =gUnknown_02022C98 - ldr r1, [r0] - b _080255E8 - .pool -_080254D4: - bl sub_802A770 - cmp r0, 0 - beq _080254DE - b _0802563C -_080254DE: - movs r0, 0x3 - bl sub_80292E0 - ldr r0, =gUnknown_02022C98 - ldr r1, [r0] - b _080255E8 - .pool -_080254F0: - bl sub_8028FCC - bl sub_80272E8 - ldr r0, =gUnknown_02022C98 - ldr r1, [r0] - b _080255E8 - .pool -_08025504: - bl sub_802A794 - lsls r0, 24 - lsrs r0, 24 - mov r1, sp - strb r0, [r1] - cmp r0, 0 - bne _08025516 - b _0802563C -_08025516: - ldr r0, =gUnknown_02022C98 - ldr r1, [r0] - b _080255E8 - .pool -_08025520: - bl sub_802A770 - cmp r0, 0 - beq _0802552A - b _0802563C -_0802552A: - movs r0, 0x5 - bl sub_80292E0 - ldr r0, =gUnknown_02022C98 - ldr r1, [r0] - b _080255E8 - .pool -_0802553C: - bl sub_802A794 - mov r1, sp - strb r0, [r1] - movs r0, 0 - movs r2, 0x1 - bl SendBlock - lsls r0, 24 - cmp r0, 0 - beq _0802563C - ldr r2, =gUnknown_02022C98 - ldr r1, [r2] - movs r0, 0 - strb r0, [r1, 0x8] - ldr r1, [r2] - b _080255E8 - .pool -_08025564: - bl IsLinkTaskFinished - lsls r0, 24 - cmp r0, 0 - beq _0802563C - ldr r0, =gUnknown_02022C98 - ldr r1, [r0] - b _080255E8 - .pool -_08025578: - bl sub_8025170 - cmp r0, 0 - beq _080255BE - movs r2, 0 - ldr r1, =gUnknown_02022C98 - ldr r0, [r1] - adds r0, 0x24 - ldrb r0, [r0] - cmp r2, r0 - bcs _080255BE - adds r3, r1, 0 - movs r5, 0x86 - lsls r5, 1 - ldr r4, =gBlockRecvBuffer -_08025596: - ldr r1, [r3] - adds r1, r2, r1 - adds r1, r5 - lsls r0, r2, 8 - adds r0, r4 - ldrb r0, [r0] - strb r0, [r1] - ldr r1, [r3] - adds r0, r1, 0 - adds r0, 0x24 - ldrb r0, [r0] - strb r0, [r1, 0x8] - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - ldr r0, [r3] - adds r0, 0x24 - ldrb r0, [r0] - cmp r2, r0 - bcc _08025596 -_080255BE: - ldr r4, =gUnknown_02022C98 - ldr r2, [r4] - adds r1, r2, 0 - adds r1, 0x24 - ldrb r0, [r2, 0x8] - ldrb r1, [r1] - cmp r0, r1 - bcc _080255F8 - ldrb r0, [r2, 0x14] - adds r0, 0x1 - strb r0, [r2, 0x14] - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x77 - bls _0802563C - bl sub_8027608 - movs r0, 0x6 - bl sub_80292E0 - ldr r1, [r4] -_080255E8: - ldrb r0, [r1, 0x10] - adds r0, 0x1 - strb r0, [r1, 0x10] - b _0802563C - .pool -_080255F8: - bl sub_8027554 - b _0802563C -_080255FE: - movs r0, 0x8 - bl sub_8026240 - b _0802563C -_08025606: - bl sub_802A770 - cmp r0, 0 - bne _0802563C - movs r2, 0 - ldr r1, [r4] - adds r0, r1, 0 - adds r0, 0x24 - ldrb r0, [r0] - cmp r2, r0 - bcs _08025636 - movs r4, 0x86 - lsls r4, 1 - adds r3, r1, r4 - adds r1, r0, 0 -_08025624: - adds r0, r3, r2 - ldrb r0, [r0] - cmp r0, 0x2 - beq _080255FE - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, r1 - bcc _08025624 -_08025636: - movs r0, 0xA - bl sub_8026240 -_0802563C: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_8025470 - - thumb_func_start sub_8025644 -sub_8025644: @ 8025644 - push {r4,lr} - ldr r4, =gUnknown_02022C98 - ldr r0, [r4] - ldrb r0, [r0, 0x10] - cmp r0, 0x1 - beq _08025672 - cmp r0, 0x1 - bgt _08025660 - cmp r0, 0 - beq _08025666 - b _08025692 - .pool -_08025660: - cmp r0, 0x2 - beq _0802567C - b _08025692 -_08025666: - bl sub_800AC34 - movs r0, 0x7 - bl sub_80292E0 - b _08025688 -_08025672: - bl sub_802A770 - cmp r0, 0 - bne _080256A0 - b _08025688 -_0802567C: - bl sub_802A794 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x5 - bne _080256A0 -_08025688: - ldr r1, [r4] - ldrb r0, [r1, 0x10] - adds r0, 0x1 - strb r0, [r1, 0x10] - b _080256A0 -_08025692: - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - bne _080256A0 - movs r0, 0x9 - bl sub_8026240 -_080256A0: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8025644 - - thumb_func_start sub_80256AC -sub_80256AC: @ 80256AC - push {r4,lr} - sub sp, 0x4 - ldr r4, =gUnknown_02022C98 - ldr r0, [r4] - ldrb r1, [r0, 0x10] - cmp r1, 0x1 - beq _080256E0 - cmp r1, 0x1 - bgt _080256C8 - cmp r1, 0 - beq _080256CE - b _08025728 - .pool -_080256C8: - cmp r1, 0x2 - beq _080256F8 - b _08025728 -_080256CE: - movs r0, 0x1 - negs r0, r0 - str r1, [sp] - movs r1, 0 - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - b _0802571A -_080256E0: - bl UpdatePaletteFade - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0802574C - b _0802571A - .pool -_080256F8: - bl sub_8028B80 - bl sub_80287E4 - ldr r0, [r4] - adds r0, 0x24 - ldrb r0, [r0] - bl sub_8028614 - bl sub_8028E84 - ldr r1, =gUnknown_03000DB0 - movs r0, 0x1 - str r0, [r1] - movs r0, 0x8 - bl sub_80292E0 -_0802571A: - ldr r1, [r4] - ldrb r0, [r1, 0x10] - adds r0, 0x1 - strb r0, [r1, 0x10] - b _0802574C - .pool -_08025728: - bl sub_802A770 - cmp r0, 0 - bne _0802574C - ldr r4, =gUnknown_02022C98 - ldr r0, [r4] - ldr r0, [r0] - bl SetMainCallback2 - ldr r0, [r4] - ldrb r0, [r0, 0x4] - bl DestroyTask - ldr r0, [r4] - bl Free - bl FreeAllWindowBuffers -_0802574C: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80256AC - - thumb_func_start sub_8025758 -sub_8025758: @ 8025758 - push {r4,lr} - sub sp, 0x4 - ldr r4, =gUnknown_02022C98 - ldr r1, [r4] - ldrb r0, [r1, 0x10] - cmp r0, 0x6 - bls _08025768 - b _0802585C -_08025768: - lsls r0, 2 - ldr r1, =_0802577C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0802577C: - .4byte _08025798 - .4byte _08025838 - .4byte _080257B0 - .4byte _08025802 - .4byte _08025808 - .4byte _08025818 - .4byte _08025838 -_08025798: - movs r0, 0x9 - bl sub_80292E0 - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - b _08025848 -_080257B0: - movs r0, 0 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - movs r0, 0x2 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0x2 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - movs r0, 0x3 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0x3 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - b _08025848 -_08025802: - bl StopMapMusic - b _08025848 -_08025808: - ldr r0, =0x0000021e - bl PlayNewMapMusic - bl sub_8028E4C - b _08025848 - .pool -_08025818: - movs r4, 0x1 - negs r4, r4 - adds r0, r4, 0 - movs r1, 0x10 - movs r2, 0 - bl BlendPalettes - movs r0, 0 - str r0, [sp] - adds r0, r4, 0 - movs r1, 0 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - b _08025848 -_08025838: - bl UpdatePaletteFade - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0802588C -_08025848: - ldr r0, =gUnknown_02022C98 - ldr r1, [r0] - ldrb r0, [r1, 0x10] - adds r0, 0x1 - strb r0, [r1, 0x10] - b _0802588C - .pool -_0802585C: - ldrb r0, [r1, 0x4] - bl DestroyTask - ldr r0, =sub_802589C - bl sub_802621C - bl sub_802903C - ldr r0, [r4] - bl sub_8024A30 - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - bne _08025882 - ldr r0, [r4] - adds r0, 0x24 - movs r1, 0x1 - strb r1, [r0] -_08025882: - bl sub_80273F0 - movs r0, 0 - bl sub_8028EC8 -_0802588C: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8025758 - thumb_func_start sub_802589C sub_802589C: @ 802589C push {r4,r5,lr} diff --git a/src/dodrio_berry_picking.c b/src/dodrio_berry_picking.c index b2fa006a2..c5736ec13 100644 --- a/src/dodrio_berry_picking.c +++ b/src/dodrio_berry_picking.c @@ -1,6 +1,8 @@ #include "global.h" #include "alloc.h" #include "palette.h" +#include "window.h" +#include "bg.h" #include "link.h" #include "link_rfu.h" #include "task.h" @@ -42,7 +44,8 @@ struct DodrioBerryPickingSubstruct_318C struct DodrioBerryPickingStruct { /*0x0000*/ void (*savedCallback)(void); - /*0x0004*/ u8 filler_0004[4]; + /*0x0004*/ u8 unk_0004; + /*0x0005*/ u8 filler_0005[3]; /*0x0008*/ u8 unk_0008; /*0x0009*/ u8 filler_0009[3]; /*0x000C*/ u8 unk_000C; @@ -156,21 +159,32 @@ void sub_8026B28(void); void sub_8026B5C(u8, u8*, u8*); bool32 sub_8026C50(void); bool32 sub_8026C90(void); +void sub_80272E8(void); void sub_80272A4(void); void sub_80273F0(void); void sub_802749C(void); u8 sub_8027518(u8); +void sub_8027554(void); +void sub_8027608(void); +u32 sub_8027748(void); void sub_80283A8(void); void sub_8028408(struct DodrioBerryPickingSubstruct_318C *, u8, u8, u8); void sub_8028504(u8); +void sub_8028614(u8); void sub_802868C(u8, u8); void sub_8028734(void); +void sub_80287E4(void); void sub_80289E8(u8); void sub_8028A34(void); void sub_8028A88(void); +void sub_8028B80(void); void sub_8028D44(void); void sub_8028DFC(void); +void sub_8028E4C(void); +void sub_8028E84(void); void sub_8028EC8(u8); +void sub_8028FCC(void); +void sub_802903C(void); void sub_8029274(struct DodrioBerryPickingSubstruct_0160 *); void sub_80292E0(u8); bool32 sub_802A770(void); @@ -712,3 +726,224 @@ void sub_8025324(void) break; } } + +void sub_8025470(void) +{ + u8 sp0; + u8 i; + + switch (gUnknown_02022C98->unk_0010) + { + case 0: + if (sub_8027748() >= 3000) + { + sub_80292E0(4); + } + gUnknown_02022C98->unk_0010++; + break; + case 1: + if (!sub_802A770()) + { + sub_80292E0(3); + gUnknown_02022C98->unk_0010++; + } + break; + case 2: + sub_8028FCC(); + sub_80272E8(); + gUnknown_02022C98->unk_0010++; + break; + case 3: + if ((sp0 = sub_802A794()) != 0) + { + gUnknown_02022C98->unk_0010++; + } + break; + case 4: + if (!sub_802A770()) + { + sub_80292E0(5); + gUnknown_02022C98->unk_0010++; + } + break; + case 5: + sp0 = sub_802A794(); + if (SendBlock(0, &sp0, sizeof(sp0))) + { + gUnknown_02022C98->unk_0008 = 0; + gUnknown_02022C98->unk_0010++; + } + break; + case 6: + if (IsLinkTaskFinished()) + { + gUnknown_02022C98->unk_0010++; + } + break; + case 7: + if (sub_8025170()) + { + for (i = 0; i < gUnknown_02022C98->unk_0024; i++) + { + *(gUnknown_02022C98->unk_010C + i) = *(u8 *)gBlockRecvBuffer[i]; + gUnknown_02022C98->unk_0008 = gUnknown_02022C98->unk_0024; + } + } + if (gUnknown_02022C98->unk_0008 >= gUnknown_02022C98->unk_0024) { + if (++gUnknown_02022C98->unk_0014 >= 120) + { + sub_8027608(); + sub_80292E0(6); + gUnknown_02022C98->unk_0010++; + } + } + else + { + sub_8027554(); + } + break; + default: + if (!sub_802A770()) + { + for (i = 0; i < gUnknown_02022C98->unk_0024; i++) + { + if (gUnknown_02022C98->unk_010C[i] == 2) + { + sub_8026240(8); + return; + } + } + sub_8026240(10); + } + break; + } +} + +void sub_8025644(void) +{ + switch (gUnknown_02022C98->unk_0010) + { + case 0: + sub_800AC34(); + sub_80292E0(7); + gUnknown_02022C98->unk_0010++; + break; + case 1: + if (!sub_802A770()) + { + gUnknown_02022C98->unk_0010++; + } + break; + case 2: + if (sub_802A794() == 5) + { + gUnknown_02022C98->unk_0010++; + } + break; + default: + if (gReceivedRemoteLinkPlayers == 0) + { + sub_8026240(9); + } + break; + } +} + +void sub_80256AC(void) +{ + switch (gUnknown_02022C98->unk_0010) + { + case 0: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gUnknown_02022C98->unk_0010++; + break; + case 1: + UpdatePaletteFade(); + if (!gPaletteFade.active) + { + gUnknown_02022C98->unk_0010++; + } + break; + case 2: + sub_8028B80(); + sub_80287E4(); + sub_8028614(gUnknown_02022C98->unk_0024); + sub_8028E84(); + gUnknown_03000DB0 = TRUE; + sub_80292E0(8); + gUnknown_02022C98->unk_0010++; + break; + default: + if (!sub_802A770()) + { + SetMainCallback2(gUnknown_02022C98->savedCallback); + DestroyTask(gUnknown_02022C98->unk_0004); + Free(gUnknown_02022C98); + FreeAllWindowBuffers(); + } + break; + } +} + +void sub_8025758(void) +{ + switch (gUnknown_02022C98->unk_0010) + { + case 0: + sub_80292E0(9); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gUnknown_02022C98->unk_0010++; + break; + case 1: + UpdatePaletteFade(); + if (!gPaletteFade.active) + { + gUnknown_02022C98->unk_0010++; + } + break; + case 2: + ChangeBgX(0, 0, 0); + ChangeBgY(0, 0, 0); + ChangeBgX(1, 0, 0); + ChangeBgY(1, 0, 0); + ChangeBgX(2, 0, 0); + ChangeBgY(2, 0, 0); + ChangeBgX(3, 0, 0); + ChangeBgY(3, 0, 0); + gUnknown_02022C98->unk_0010++; + break; + case 3: + StopMapMusic(); + gUnknown_02022C98->unk_0010++; + break; + case 4: + PlayNewMapMusic(MUS_RG_KINOMIKUI); + sub_8028E4C(); + gUnknown_02022C98->unk_0010++; + break; + case 5: + BlendPalettes(0xFFFFFFFF, 16, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); + gUnknown_02022C98->unk_0010++; + break; + case 6: + UpdatePaletteFade(); + if (!gPaletteFade.active) + { + gUnknown_02022C98->unk_0010++; + } + break; + default: + DestroyTask(gUnknown_02022C98->unk_0004); + sub_802621C(sub_802589C); + sub_802903C(); + sub_8024A30(gUnknown_02022C98); + if (gReceivedRemoteLinkPlayers == 0) + { + gUnknown_02022C98->unk_0024 = 1; + } + sub_80273F0(); + sub_8028EC8(0); + break; + } +} From e3a11bc3caae92a94370f99c9d263c7f08b95e32 Mon Sep 17 00:00:00 2001 From: scnorton Date: Mon, 25 Mar 2019 15:26:23 -0400 Subject: [PATCH 08/13] through sub_80259FC --- asm/dodrio_berry_picking.s | 430 ------------------------------------- include/link_rfu.h | 1 + src/dodrio_berry_picking.c | 162 +++++++++++++- 3 files changed, 158 insertions(+), 435 deletions(-) diff --git a/asm/dodrio_berry_picking.s b/asm/dodrio_berry_picking.s index 9b7172029..5a771737d 100755 --- a/asm/dodrio_berry_picking.s +++ b/asm/dodrio_berry_picking.s @@ -5,436 +5,6 @@ .text - thumb_func_start sub_802589C -sub_802589C: @ 802589C - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, =gUnknown_02022C98 - ldr r0, [r1] - ldrb r0, [r0, 0x10] - adds r4, r1, 0 - cmp r0, 0x1 - beq _080258C8 - cmp r0, 0x1 - bgt _080258BC - cmp r0, 0 - beq _080258C2 - b _080258E0 - .pool -_080258BC: - cmp r0, 0x2 - beq _080258CE - b _080258E0 -_080258C2: - bl sub_8026264 - b _080258D2 -_080258C8: - bl sub_80286E4 - b _080258D6 -_080258CE: - bl sub_8028828 -_080258D2: - cmp r0, 0x1 - bne _08025904 -_080258D6: - ldr r1, [r4] - ldrb r0, [r1, 0x10] - adds r0, 0x1 - strb r0, [r1, 0x10] - b _08025904 -_080258E0: - ldr r0, [r4] - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0 - beq _080258F8 - ldr r0, =sub_8024D4C - bl sub_802621C - b _080258FE - .pool -_080258F8: - ldr r0, =sub_8024D84 - bl sub_802621C -_080258FE: - adds r0, r5, 0 - bl DestroyTask -_08025904: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_802589C - - thumb_func_start sub_8025910 -sub_8025910: @ 8025910 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r5, r0, r1 - movs r0, 0 - ldrsh r4, [r5, r0] - cmp r4, 0x1 - beq _0802596C - cmp r4, 0x1 - bgt _08025938 - cmp r4, 0 - beq _0802593E - b _080259E8 - .pool -_08025938: - cmp r4, 0x2 - beq _0802597E - b _080259E8 -_0802593E: - ldr r6, =gUnknown_02022C98 - ldr r1, [r6] - adds r0, r1, 0 - adds r0, 0x28 - ldrb r0, [r0] - lsls r0, 2 - ldr r2, =0x0000318c - adds r0, r2 - adds r1, r0 - movs r0, 0 - movs r2, 0x1 - bl SendBlock - lsls r0, 24 - cmp r0, 0 - beq _080259E8 - ldr r0, [r6] - strb r4, [r0, 0x8] - b _08025976 - .pool -_0802596C: - bl IsLinkTaskFinished - lsls r0, 24 - cmp r0, 0 - beq _080259E8 -_08025976: - ldrh r0, [r5] - adds r0, 0x1 - strh r0, [r5] - b _080259E8 -_0802597E: - bl sub_8025170 - cmp r0, 0 - beq _080259C4 - movs r2, 0 - ldr r1, =gUnknown_02022C98 - ldr r0, [r1] - adds r0, 0x24 - ldrb r0, [r0] - cmp r2, r0 - bcs _080259C4 - adds r3, r1, 0 - ldr r5, =gBlockRecvBuffer - ldr r4, =0x0000318c -_0802599A: - ldr r0, [r3] - lsls r1, r2, 2 - adds r1, r0 - adds r1, r4 - lsls r0, r2, 8 - adds r0, r5 - ldrb r0, [r0] - strb r0, [r1] - ldr r1, [r3] - adds r0, r1, 0 - adds r0, 0x24 - ldrb r0, [r0] - strb r0, [r1, 0x8] - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - ldr r0, [r3] - adds r0, 0x24 - ldrb r0, [r0] - cmp r2, r0 - bcc _0802599A -_080259C4: - ldr r4, =gUnknown_02022C98 - ldr r0, [r4] - adds r1, r0, 0 - adds r1, 0x24 - ldrb r0, [r0, 0x8] - ldrb r1, [r1] - cmp r0, r1 - bcc _080259E8 - adds r0, r6, 0 - bl DestroyTask - movs r0, 0x6 - bl sub_80292E0 - ldr r1, [r4] - ldrb r0, [r1, 0x10] - adds r0, 0x1 - strb r0, [r1, 0x10] -_080259E8: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8025910 - - thumb_func_start sub_80259FC -sub_80259FC: @ 80259FC - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x18 - ldr r6, =gUnknown_02022C98 - ldr r0, [r6] - adds r1, r0, 0 - adds r1, 0x24 - ldrb r7, [r1] - ldr r2, =0x000031a0 - adds r1, r0, r2 - ldr r3, =0x000031cc - adds r2, r0, r3 - ldr r4, =0x00003208 - adds r3, r0, r4 - ldr r5, =0x00003244 - adds r4, r0, r5 - str r4, [sp] - adds r5, 0x3C - adds r4, r0, r5 - str r4, [sp, 0x4] - adds r5, 0x3C - adds r4, r0, r5 - str r4, [sp, 0x8] - adds r4, r0, 0 - adds r4, 0x40 - str r4, [sp, 0xC] - movs r5, 0x90 - lsls r5, 1 - adds r4, r0, r5 - str r4, [sp, 0x10] - movs r4, 0x96 - lsls r4, 1 - adds r0, r4 - str r0, [sp, 0x14] - movs r0, 0 - bl sub_8028164 - ldr r1, [r6] - ldr r5, =0x000031b0 - adds r2, r1, r5 - str r0, [r2] - movs r0, 0x94 - lsls r0, 1 - adds r1, r0 - movs r0, 0x1 - strb r0, [r1] - movs r5, 0x1 - cmp r5, r7 - bcs _08025AA4 -_08025A60: - ldr r1, [r6] - adds r0, r1, 0 - adds r0, 0xA8 - adds r0, r5 - ldrb r0, [r0] - cmp r0, 0 - bne _08025A9A - lsls r0, r5, 4 - subs r0, r5 - lsls r4, r0, 2 - adds r1, r4, r1 - ldr r2, =0x000031cc - adds r1, r2 - adds r0, r5, 0 - bl sub_8028318 - adds r1, r0, 0 - cmp r1, 0 - bne _08025A9A - ldr r0, [r6] - adds r0, r4 - ldr r3, =0x000031cc - adds r0, r3 - strb r1, [r0] - ldr r0, [r6] - movs r4, 0x94 - lsls r4, 1 - adds r0, r4 - strb r1, [r0] -_08025A9A: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, r7 - bcc _08025A60 -_08025AA4: - ldr r5, =gUnknown_02022C98 - ldr r1, [r5] - movs r6, 0x92 - lsls r6, 1 - adds r1, r6 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3B - bls _08025B02 - ldr r1, [r5] - movs r2, 0x94 - lsls r2, 1 - adds r0, r1, r2 - ldrb r4, [r0] - cmp r4, 0 - beq _08025AF0 - bl sub_8011AC8 - ldr r0, [r5] - adds r0, r6 - movs r1, 0 - strb r1, [r0] - b _08025B02 - .pool -_08025AF0: - adds r0, r1, r6 - ldrb r0, [r0] - cmp r0, 0x46 - bls _08025B02 - bl sub_8011AC8 - ldr r0, [r5] - adds r0, r6 - strb r4, [r0] -_08025B02: - movs r5, 0 - cmp r5, r7 - bcs _08025BF6 - ldr r3, =0x000031cc - mov r12, r3 - ldr r4, =gUnknown_02022C98 - mov r8, r4 -_08025B10: - mov r6, r8 - ldr r2, [r6] - lsls r0, r5, 4 - subs r1, r0, r5 - lsls r1, 2 - adds r1, r2, r1 - add r1, r12 - ldrb r1, [r1] - adds r6, r0, 0 - cmp r1, 0 - beq _08025B36 - adds r0, r2, 0 - adds r0, 0xA8 - adds r1, r0, r5 - ldrb r0, [r1] - cmp r0, 0 - bne _08025B36 - movs r0, 0x1 - strb r0, [r1] -_08025B36: - adds r3, r4, 0 - ldr r1, [r3] - adds r0, r1, 0 - adds r0, 0xA8 - adds r0, r5 - ldrb r0, [r0] - cmp r0, 0x3 - bgt _08025B54 - cmp r0, 0x1 - bge _08025B5A - b _08025BEC - .pool -_08025B54: - cmp r0, 0x4 - beq _08025BA8 - b _08025BEC -_08025B5A: - adds r1, 0xB0 - adds r1, r5 - ldrb r0, [r1] - adds r0, 0x1 - movs r2, 0 - strb r0, [r1] - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x5 - bls _08025BEC - ldr r0, [r3] - adds r0, 0xB0 - adds r0, r5 - strb r2, [r0] - ldr r0, [r3] - adds r0, 0xA8 - adds r0, r5 - strb r2, [r0] - ldr r0, [r3] - subs r1, r6, r5 - lsls r1, 2 - adds r0, r1 - add r0, r12 - strb r2, [r0] - ldr r0, [r3] - adds r0, r1 - ldr r6, =0x000031d0 - adds r0, r6 - strb r2, [r0] - ldr r0, [r3] - adds r0, r1 - ldr r1, =0x000031d4 - adds r0, r1 - b _08025BEA - .pool -_08025BA8: - adds r1, 0xB0 - adds r1, r5 - ldrb r0, [r1] - adds r0, 0x1 - movs r2, 0 - strb r0, [r1] - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x27 - bls _08025BEC - ldr r0, [r4] - adds r0, 0xB0 - adds r0, r5 - strb r2, [r0] - ldr r0, [r4] - adds r0, 0xA8 - adds r0, r5 - strb r2, [r0] - ldr r0, [r4] - subs r1, r6, r5 - lsls r1, 2 - adds r0, r1 - add r0, r12 - strb r2, [r0] - ldr r0, [r4] - adds r0, r1 - ldr r3, =0x000031d0 - adds r0, r3 - strb r2, [r0] - ldr r0, [r4] - adds r0, r1 - ldr r6, =0x000031d4 - adds r0, r6 -_08025BEA: - strb r2, [r0] -_08025BEC: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, r7 - bcc _08025B10 -_08025BF6: - add sp, 0x18 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80259FC - thumb_func_start sub_8025C0C sub_8025C0C: @ 8025C0C push {r4-r7,lr} diff --git a/include/link_rfu.h b/include/link_rfu.h index 5b8ccd9fb..3bb1ef4f1 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -284,5 +284,6 @@ bool8 sub_800DE7C(struct UnkLinkRfuStruct_02022B14 *buff1, u8 *buff2, u8 idx); s32 sub_800E87C(u8 idx); void sub_8011BA4(void); void sub_8010198(void); +void sub_8011AC8(void); #endif //GUARD_LINK_RFU_H diff --git a/src/dodrio_berry_picking.c b/src/dodrio_berry_picking.c index c5736ec13..b9d41241f 100644 --- a/src/dodrio_berry_picking.c +++ b/src/dodrio_berry_picking.c @@ -29,11 +29,15 @@ struct DodrioBerryPickingStruct_2022CF4 struct DodrioBerryPickingSubstruct_31A0 { - u8 unk_00[0x2C - 0x00]; + u8 unk_00[0x10]; + u32 unk_10; + u8 filler_14[0x18]; u8 unk_2C; u8 filler_2D[3]; u8 unk_30; - u8 filler_31[11]; + u8 filler_31[3]; + u8 unk_34; + u8 filler_35[7]; }; // size = 0x3C struct DodrioBerryPickingSubstruct_318C @@ -99,7 +103,10 @@ struct DodrioBerryPickingStruct /*0x0118*/ u32 unk_0118; /*0x011C*/ u32 unk_011C; /*0x0120*/ u32 unk_0120; - /*0x0124*/ u8 filler_0124[8]; + /*0x0124*/ u8 unk_0124; + /*0x0125*/ u8 filler_0125[3]; + /*0x0128*/ u8 unk_0128; + // align 2 /*0x012C*/ u32 unk_012C; /*0x0130*/ u32 unk_0130[5]; /*0x0144*/ u8 filler_0144[0x1C]; @@ -152,6 +159,7 @@ void sub_80261F8(struct DodrioBerryPickingSubstruct_318C *, struct Pokemon *); void sub_802620C(TaskFunc, u8); void sub_802621C(TaskFunc); void sub_8026240(u8); +bool32 sub_8026264(void); void sub_80262C0(void); void sub_802671C(void); void sub_8026AF4(void); @@ -167,6 +175,8 @@ u8 sub_8027518(u8); void sub_8027554(void); void sub_8027608(void); u32 sub_8027748(void); +u32 sub_8028164(u32 unused, struct DodrioBerryPickingSubstruct_31A0 *, u8 *, u8 *, u8 *, u8 *, u8 *, u8 *, u32 *, u32 *); +u32 sub_8028318(u8, u8 *); void sub_80283A8(void); void sub_8028408(struct DodrioBerryPickingSubstruct_318C *, u8, u8, u8); void sub_8028504(u8); @@ -175,6 +185,8 @@ void sub_802868C(u8, u8); void sub_8028734(void); void sub_80287E4(void); void sub_80289E8(u8); +void sub_80286E4(void); +bool32 sub_8028828(void); void sub_8028A34(void); void sub_8028A88(void); void sub_8028B80(void); @@ -353,7 +365,7 @@ void sub_8024BC8(u8 taskId) } } -void sub_8024D4C(void) +void sub_8024D4C(u8 taskId) { sub_8025D04(); gUnknown_082F7AC4[gUnknown_02022C98->unk_0018](); @@ -364,7 +376,7 @@ void sub_8024D4C(void) sub_8025D50(); } -void sub_8024D84(void) +void sub_8024D84(u8 taskId) { sub_8025E0C(); gUnknown_082F7AF4[gUnknown_02022C98->unk_0018](); @@ -947,3 +959,143 @@ void sub_8025758(void) break; } } + +void sub_802589C(u8 taskId) +{ + switch (gUnknown_02022C98->unk_0010) + { + case 0: + if (sub_8026264() == 1) + { + gUnknown_02022C98->unk_0010++; + } + break; + case 1: + sub_80286E4(); + gUnknown_02022C98->unk_0010++; + break; + case 2: + if (sub_8028828() == 1) + { + gUnknown_02022C98->unk_0010++; + } + break; + default: + if (gUnknown_02022C98->unk_0020 != 0) + { + sub_802621C(sub_8024D4C); + } + else + { + sub_802621C(sub_8024D84); + } + DestroyTask(taskId); + break; + } +} + +void sub_8025910(u8 taskId) +{ + s16 * data = gTasks[taskId].data; + u8 i; + + switch (data[0]) + { + case 0: + if (SendBlock(0, &gUnknown_02022C98->unk_318C[gUnknown_02022C98->multiplayerId].isShiny, sizeof(gUnknown_02022C98->unk_318C[gUnknown_02022C98->multiplayerId].isShiny))) + { + gUnknown_02022C98->unk_0008 = 0; + data[0]++; + } + break; + case 1: + if (IsLinkTaskFinished()) + { + data[0]++; + } + break; + case 2: + if (sub_8025170()) + { + for (i = 0; i < gUnknown_02022C98->unk_0024; i++) + { + *(u8 *)&gUnknown_02022C98->unk_318C[i] = *(u8 *)gBlockRecvBuffer[i]; + gUnknown_02022C98->unk_0008 = gUnknown_02022C98->unk_0024; + } + } + if (gUnknown_02022C98->unk_0008 >= gUnknown_02022C98->unk_0024) + { + DestroyTask(taskId); + sub_80292E0(6); + gUnknown_02022C98->unk_0010++; + } + break; + } +} + +void sub_80259FC(void) +{ + u8 i; + u8 r7 = gUnknown_02022C98->unk_0024; + + gUnknown_02022C98->unk_31A0[0].unk_10 = sub_8028164(0, &gUnknown_02022C98->unk_31A0[0], &gUnknown_02022C98->unk_31A0[0].unk_2C, &gUnknown_02022C98->unk_31A0[1].unk_2C, &gUnknown_02022C98->unk_31A0[2].unk_2C, &gUnknown_02022C98->unk_31A0[3].unk_2C, &gUnknown_02022C98->unk_31A0[4].unk_2C, &gUnknown_02022C98->unk_0040, &gUnknown_02022C98->unk_0120, &gUnknown_02022C98->unk_012C); + gUnknown_02022C98->unk_0128 = 1; + + for (i = 1; i < r7; i++) + { + if ( gUnknown_02022C98->unk_00A8[i] == 0 + && sub_8028318(i, &gUnknown_02022C98->unk_31A0[i].unk_2C) == 0) + { + gUnknown_02022C98->unk_31A0[i].unk_2C = 0; + gUnknown_02022C98->unk_0128 = 0; + } + } + if (++gUnknown_02022C98->unk_0124 >= 60) + { + if (gUnknown_02022C98->unk_0128 != 0) + { + sub_8011AC8(); + gUnknown_02022C98->unk_0124 = 0; + } + else if (gUnknown_02022C98->unk_0124 > 70) + { + sub_8011AC8(); + gUnknown_02022C98->unk_0124 = 0; + } + } + + for (i = 0; i < r7; i++) + { + if ( gUnknown_02022C98->unk_31A0[i].unk_2C != 0 + && gUnknown_02022C98->unk_00A8[i] == 0) + { + gUnknown_02022C98->unk_00A8[i] = 1; + } + switch (gUnknown_02022C98->unk_00A8[i]) + { + case 0: + default: + break; + case 1 ... 3: + if (++gUnknown_02022C98->unk_00B0[i] >= 6) + { + gUnknown_02022C98->unk_00B0[i] = 0; + gUnknown_02022C98->unk_00A8[i] = 0; + gUnknown_02022C98->unk_31A0[i].unk_2C = 0; + gUnknown_02022C98->unk_31A0[i].unk_30 = 0; + gUnknown_02022C98->unk_31A0[i].unk_34 = 0; + } + break; + case 4: + if (++gUnknown_02022C98->unk_00B0[i] >= 40) + { + gUnknown_02022C98->unk_00B0[i] = 0; + gUnknown_02022C98->unk_00A8[i] = 0; + gUnknown_02022C98->unk_31A0[i].unk_2C = 0; + gUnknown_02022C98->unk_31A0[i].unk_30 = 0; + gUnknown_02022C98->unk_31A0[i].unk_34 = 0; + } + break; + } + } +} From 5de624783c4e99df9f7af9e8c1026c2a161225c7 Mon Sep 17 00:00:00 2001 From: scnorton Date: Mon, 25 Mar 2019 17:27:27 -0400 Subject: [PATCH 09/13] through sub_8026044 --- asm/dodrio_berry_picking.s | 697 ------------------------------------- src/dodrio_berry_picking.c | 219 +++++++++++- 2 files changed, 217 insertions(+), 699 deletions(-) diff --git a/asm/dodrio_berry_picking.s b/asm/dodrio_berry_picking.s index 5a771737d..cb3b042d9 100755 --- a/asm/dodrio_berry_picking.s +++ b/asm/dodrio_berry_picking.s @@ -5,703 +5,6 @@ .text - thumb_func_start sub_8025C0C -sub_8025C0C: @ 8025C0C - push {r4-r7,lr} - sub sp, 0x18 - ldr r5, =gUnknown_02022C98 - ldr r0, [r5] - adds r1, r0, 0 - adds r1, 0x24 - ldrb r6, [r1] - ldr r2, =0x000031a0 - adds r1, r0, r2 - ldr r3, =0x000031cc - adds r2, r0, r3 - ldr r4, =0x00003208 - adds r3, r0, r4 - ldr r7, =0x00003244 - adds r4, r0, r7 - str r4, [sp] - adds r7, 0x3C - adds r4, r0, r7 - str r4, [sp, 0x4] - adds r7, 0x3C - adds r4, r0, r7 - str r4, [sp, 0x8] - adds r4, r0, 0 - adds r4, 0x40 - str r4, [sp, 0xC] - movs r7, 0x90 - lsls r7, 1 - adds r4, r0, r7 - str r4, [sp, 0x10] - movs r4, 0x96 - lsls r4, 1 - adds r0, r4 - str r0, [sp, 0x14] - movs r0, 0 - bl sub_8028164 - ldr r1, [r5] - ldr r7, =0x000031b0 - adds r2, r1, r7 - str r0, [r2] - movs r0, 0x94 - lsls r0, 1 - adds r1, r0 - movs r0, 0x1 - strb r0, [r1] - movs r4, 0x1 - cmp r4, r6 - bcs _08025C9C -_08025C6C: - adds r0, r4, 0 - bl sub_8028374 - cmp r0, 0 - beq _08025C92 - ldr r0, =gUnknown_02022C98 - ldr r2, [r0] - lsls r1, r4, 2 - movs r3, 0x98 - lsls r3, 1 - adds r0, r2, r3 - adds r0, r1 - movs r1, 0x1 - str r1, [r0] - movs r7, 0x94 - lsls r7, 1 - adds r1, r2, r7 - movs r0, 0 - strb r0, [r1] -_08025C92: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, r6 - bcc _08025C6C -_08025C9C: - ldr r5, =gUnknown_02022C98 - ldr r1, [r5] - movs r6, 0x92 - lsls r6, 1 - adds r1, r6 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3B - bls _08025CFA - ldr r1, [r5] - movs r2, 0x94 - lsls r2, 1 - adds r0, r1, r2 - ldrb r4, [r0] - cmp r4, 0 - beq _08025CE8 - bl sub_8011AC8 - ldr r0, [r5] - adds r0, r6 - movs r1, 0 - strb r1, [r0] - b _08025CFA - .pool -_08025CE8: - adds r0, r1, r6 - ldrb r0, [r0] - cmp r0, 0x46 - bls _08025CFA - bl sub_8011AC8 - ldr r0, [r5] - adds r0, r6 - strb r4, [r0] -_08025CFA: - add sp, 0x18 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8025C0C - - thumb_func_start sub_8025D04 -sub_8025D04: @ 8025D04 - push {r4,r5,lr} - ldr r5, =gUnknown_02022C98 - ldr r0, [r5] - ldrb r0, [r0, 0x18] - cmp r0, 0x4 - beq _08025D40 - cmp r0, 0x4 - bgt _08025D20 - cmp r0, 0x3 - beq _08025D26 - b _08025D4A - .pool -_08025D20: - cmp r0, 0xB - beq _08025D46 - b _08025D4A -_08025D26: - bl sub_8026BB8 - adds r4, r0, 0 - cmp r4, 0x1 - bne _08025D4A - bl sub_8026C28 - ldr r0, [r5] - movs r1, 0x8E - lsls r1, 1 - adds r0, r1 - str r4, [r0] - b _08025D4A -_08025D40: - bl sub_80259FC - b _08025D4A -_08025D46: - bl sub_8025C0C -_08025D4A: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_8025D04 - - thumb_func_start sub_8025D50 -sub_8025D50: @ 8025D50 - push {r4-r6,lr} - sub sp, 0x14 - ldr r0, =gUnknown_02022C98 - ldr r5, [r0] - ldrb r0, [r5, 0x18] - cmp r0, 0x4 - beq _08025D68 - cmp r0, 0xB - beq _08025DB8 - b _08025DF4 - .pool -_08025D68: - ldr r1, =0x000032cc - adds r0, r5, r1 - ldr r2, =0x000031cc - adds r1, r5, r2 - ldr r3, =0x00003208 - adds r2, r5, r3 - ldr r4, =0x00003244 - adds r3, r5, r4 - movs r6, 0xCA - lsls r6, 6 - adds r4, r5, r6 - str r4, [sp] - adds r6, 0x3C - adds r4, r5, r6 - str r4, [sp, 0x4] - adds r4, r5, 0 - adds r4, 0x40 - ldrb r4, [r4] - str r4, [sp, 0x8] - movs r6, 0x90 - lsls r6, 1 - adds r4, r5, r6 - ldr r4, [r4] - str r4, [sp, 0xC] - adds r6, 0xC - adds r4, r5, r6 - ldr r4, [r4] - str r4, [sp, 0x10] - bl sub_8027E30 - b _08025DF4 - .pool -_08025DB8: - ldr r1, =0x000032cc - adds r0, r5, r1 - ldr r2, =0x000031cc - adds r1, r5, r2 - ldr r3, =0x00003208 - adds r2, r5, r3 - ldr r4, =0x00003244 - adds r3, r5, r4 - movs r6, 0xCA - lsls r6, 6 - adds r4, r5, r6 - str r4, [sp] - adds r6, 0x3C - adds r4, r5, r6 - str r4, [sp, 0x4] - adds r4, r5, 0 - adds r4, 0x40 - ldrb r4, [r4] - str r4, [sp, 0x8] - movs r6, 0x90 - lsls r6, 1 - adds r4, r5, r6 - ldr r4, [r4] - str r4, [sp, 0xC] - adds r6, 0xC - adds r4, r5, r6 - ldr r4, [r4] - str r4, [sp, 0x10] - bl sub_8027E30 -_08025DF4: - add sp, 0x14 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8025D50 - - thumb_func_start sub_8025E0C -sub_8025E0C: @ 8025E0C - push {r4-r6,lr} - sub sp, 0x18 - ldr r0, =gUnknown_02022C98 - ldr r5, [r0] - ldrb r0, [r5, 0x18] - cmp r0, 0x4 - beq _08025E24 - cmp r0, 0xB - beq _08025E7C - b _08025EC0 - .pool -_08025E24: - adds r0, r5, 0 - adds r0, 0x28 - ldrb r0, [r0] - lsls r1, r0, 4 - subs r1, r0 - lsls r1, 2 - ldr r2, =0x000031a0 - adds r1, r2 - adds r1, r5, r1 - ldr r3, =0x000031cc - adds r2, r5, r3 - ldr r4, =0x00003208 - adds r3, r5, r4 - ldr r6, =0x00003244 - adds r4, r5, r6 - str r4, [sp] - adds r6, 0x3C - adds r4, r5, r6 - str r4, [sp, 0x4] - adds r6, 0x3C - adds r4, r5, r6 - str r4, [sp, 0x8] - adds r4, r5, 0 - adds r4, 0x40 - str r4, [sp, 0xC] - movs r6, 0x90 - lsls r6, 1 - adds r4, r5, r6 - str r4, [sp, 0x10] - adds r6, 0xC - adds r4, r5, r6 - str r4, [sp, 0x14] - bl sub_8028164 - b _08025EC0 - .pool -_08025E7C: - adds r0, r5, 0 - adds r0, 0x28 - ldrb r0, [r0] - lsls r1, r0, 4 - subs r1, r0 - lsls r1, 2 - ldr r2, =0x000031a0 - adds r1, r2 - adds r1, r5, r1 - ldr r3, =0x000031cc - adds r2, r5, r3 - ldr r4, =0x00003208 - adds r3, r5, r4 - ldr r6, =0x00003244 - adds r4, r5, r6 - str r4, [sp] - adds r6, 0x3C - adds r4, r5, r6 - str r4, [sp, 0x4] - adds r6, 0x3C - adds r4, r5, r6 - str r4, [sp, 0x8] - adds r4, r5, 0 - adds r4, 0x40 - str r4, [sp, 0xC] - movs r6, 0x90 - lsls r6, 1 - adds r4, r5, r6 - str r4, [sp, 0x10] - adds r6, 0xC - adds r4, r5, r6 - str r4, [sp, 0x14] - bl sub_8028164 -_08025EC0: - add sp, 0x18 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8025E0C - - thumb_func_start sub_8025ED8 -sub_8025ED8: @ 8025ED8 - push {r4,lr} - ldr r4, =gUnknown_02022C98 - ldr r1, [r4] - ldrb r0, [r1, 0x18] - cmp r0, 0x4 - beq _08025F0E - cmp r0, 0x4 - bgt _08025EF4 - cmp r0, 0x3 - beq _08025EFA - b _08025F40 - .pool -_08025EF4: - cmp r0, 0xB - beq _08025F24 - b _08025F40 -_08025EFA: - movs r0, 0x1 - bl sub_8027DD0 - ldr r0, [r4] - movs r1, 0x8E - lsls r1, 1 - adds r0, r1 - movs r1, 0x1 - str r1, [r0] - b _08025F40 -_08025F0E: - ldr r2, =0x000032f8 - adds r1, r2 - ldrb r0, [r1] - cmp r0, 0 - beq _08025F40 - bl sub_80282EC - b _08025F40 - .pool -_08025F24: - movs r2, 0x90 - lsls r2, 1 - adds r0, r1, r2 - ldr r0, [r0] - cmp r0, 0 - bne _08025F40 - adds r2, 0xC - adds r0, r1, r2 - ldr r0, [r0] - cmp r0, 0 - bne _08025F40 - movs r0, 0x1 - bl sub_8028350 -_08025F40: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8025ED8 - - thumb_func_start sub_8025F48 -sub_8025F48: @ 8025F48 - push {r4-r6,lr} - ldr r6, =gUnknown_02022C98 - ldr r2, [r6] - adds r0, r2, 0 - adds r0, 0x28 - ldrb r1, [r0] - lsls r0, r1, 4 - subs r0, r1 - lsls r0, 2 - adds r1, r2, r0 - ldr r3, =0x000031cc - adds r0, r1, r3 - ldrb r0, [r0] - cmp r0, 0 - bne _08025F88 - bl IsSEPlaying - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - bne _08025FEA - ldr r0, [r6] - movs r2, 0xA2 - lsls r2, 1 - adds r0, r2 - strb r1, [r0] - b _08025FEA - .pool -_08025F88: - ldr r3, =0x000031d0 - adds r0, r1, r3 - ldrb r4, [r0] - cmp r4, 0x1 - bne _08025FB8 - movs r1, 0xA2 - lsls r1, 1 - adds r0, r2, r1 - ldrb r0, [r0] - cmp r0, 0 - bne _08025FEA - movs r0, 0x1F - bl m4aSongNumStop - movs r0, 0x1F - bl PlaySE - ldr r0, [r6] - movs r2, 0xA2 - lsls r2, 1 - adds r0, r2 - b _08025FE8 - .pool -_08025FB8: - ldr r3, =0x000031d4 - adds r0, r1, r3 - ldrb r4, [r0] - cmp r4, 0x1 - bne _08025FEA - movs r5, 0xA2 - lsls r5, 1 - adds r0, r2, r5 - ldrb r0, [r0] - cmp r0, 0 - bne _08025FEA - bl IsSEPlaying - lsls r0, 24 - cmp r0, 0 - bne _08025FEA - movs r0, 0x16 - bl PlaySE - movs r0, 0x1 - bl sub_80284CC - ldr r0, [r6] - adds r0, r5 -_08025FE8: - strb r4, [r0] -_08025FEA: - ldr r0, =gUnknown_02022C98 - ldr r2, [r0] - movs r5, 0xAA - lsls r5, 1 - adds r1, r2, r5 - ldrb r1, [r1] - adds r4, r0, 0 - cmp r1, 0 - bne _0802601C - adds r0, r2, 0 - adds r0, 0x40 - ldrb r0, [r0] - cmp r0, 0x9 - bls _0802601C - bl StopMapMusic - ldr r0, [r4] - adds r0, r5 - movs r1, 0x1 - b _0802603A - .pool -_0802601C: - ldr r0, [r4] - movs r1, 0xAA - lsls r1, 1 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0x1 - bne _0802603C - movs r0, 0xB - bl PlayFanfareByFanfareNum - ldr r0, [r4] - movs r2, 0xAA - lsls r2, 1 - adds r0, r2 - movs r1, 0x2 -_0802603A: - strb r1, [r0] -_0802603C: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8025F48 - - thumb_func_start sub_8026044 -sub_8026044: @ 8026044 - push {r4-r7,lr} - mov r7, r8 - push {r7} - ldr r6, =gUnknown_02022C98 - ldr r2, [r6] - adds r0, r2, 0 - adds r0, 0x44 - ldrb r0, [r0] - mov r8, r0 - adds r0, r2, 0 - adds r0, 0x48 - ldrb r7, [r0] - subs r0, 0x20 - ldrb r1, [r0] - lsls r0, r1, 4 - subs r0, r1 - lsls r0, 2 - adds r1, r2, r0 - ldr r3, =0x000031cc - adds r0, r1, r3 - ldrb r3, [r0] - cmp r3, 0 - bne _0802609C - ldr r4, =0x000031d0 - adds r0, r1, r4 - ldrb r0, [r0] - cmp r0, 0x1 - beq _080260FE - adds r4, 0x4 - adds r0, r1, r4 - ldrb r0, [r0] - cmp r0, 0x1 - beq _080260FE - movs r1, 0xA2 - lsls r1, 1 - adds r0, r2, r1 - strb r3, [r0] - b _080260FE - .pool -_0802609C: - ldr r3, =0x000031d0 - adds r0, r1, r3 - ldrb r4, [r0] - cmp r4, 0x1 - bne _080260CC - movs r1, 0xA2 - lsls r1, 1 - adds r0, r2, r1 - ldrb r0, [r0] - cmp r0, 0 - bne _080260FE - movs r0, 0x1F - bl m4aSongNumStop - movs r0, 0x1F - bl PlaySE - ldr r0, [r6] - movs r3, 0xA2 - lsls r3, 1 - adds r0, r3 - b _080260FC - .pool -_080260CC: - ldr r4, =0x000031d4 - adds r0, r1, r4 - ldrb r4, [r0] - cmp r4, 0x1 - bne _080260FE - movs r5, 0xA2 - lsls r5, 1 - adds r0, r2, r5 - ldrb r0, [r0] - cmp r0, 0 - bne _080260FE - bl IsSEPlaying - lsls r0, 24 - cmp r0, 0 - bne _080260FE - movs r0, 0x16 - bl PlaySE - movs r0, 0x1 - bl sub_80284CC - ldr r0, [r6] - adds r0, r5 -_080260FC: - strb r4, [r0] -_080260FE: - mov r4, r8 - cmp r4, r7 - bcs _08026172 - ldr r5, =gUnknown_02022C98 -_08026106: - ldr r2, [r5] - adds r0, r2, 0 - adds r0, 0x28 - ldrb r1, [r0] - lsls r0, r1, 4 - subs r0, r1 - lsls r0, 2 - ldr r1, =0x000031a0 - adds r0, r1 - adds r0, r2, r0 - adds r1, r0, 0 - adds r1, 0x14 - adds r0, 0x1F - adds r0, r4 - ldrb r0, [r0] - cmp r0, 0x9 - bls _0802615C - movs r3, 0xA4 - lsls r3, 1 - adds r0, r2, r3 - adds r0, r4 - ldrb r0, [r0] - cmp r0, 0 - bne _08026168 - adds r0, r1, r4 - ldrb r0, [r0] - adds r0, 0x4A - bl PlaySE - ldr r0, [r5] - movs r1, 0xA4 - lsls r1, 1 - adds r0, r1 - adds r0, r4 - movs r1, 0x1 - b _08026166 - .pool -_0802615C: - movs r3, 0xA4 - lsls r3, 1 - adds r0, r2, r3 - adds r0, r4 - movs r1, 0 -_08026166: - strb r1, [r0] -_08026168: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, r7 - bcc _08026106 -_08026172: - ldr r0, =gUnknown_02022C98 - ldr r2, [r0] - movs r5, 0xAA - lsls r5, 1 - adds r1, r2, r5 - ldrb r1, [r1] - adds r4, r0, 0 - cmp r1, 0 - bne _080261A0 - adds r0, r2, 0 - adds r0, 0x40 - ldrb r0, [r0] - cmp r0, 0x9 - bls _080261A0 - bl StopMapMusic - ldr r0, [r4] - adds r0, r5 - movs r1, 0x1 - b _080261BE - .pool -_080261A0: - ldr r0, [r4] - movs r1, 0xAA - lsls r1, 1 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0x1 - bne _080261C0 - movs r0, 0xB - bl PlayFanfareByFanfareNum - ldr r0, [r4] - movs r3, 0xAA - lsls r3, 1 - adds r0, r3 - movs r1, 0x2 -_080261BE: - strb r1, [r0] -_080261C0: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8026044 - thumb_func_start sub_80261CC sub_80261CC: @ 80261CC push {lr} diff --git a/src/dodrio_berry_picking.c b/src/dodrio_berry_picking.c index b9d41241f..922b551d9 100644 --- a/src/dodrio_berry_picking.c +++ b/src/dodrio_berry_picking.c @@ -9,6 +9,7 @@ #include "main.h" #include "constants/songs.h" #include "sound.h" +#include "m4a.h" #include "pokemon_jump.h" struct DodrioBerryPickingSubstruct_0160 @@ -31,7 +32,9 @@ struct DodrioBerryPickingSubstruct_31A0 { u8 unk_00[0x10]; u32 unk_10; - u8 filler_14[0x18]; + u8 unk_14[11]; + u8 unk_1F[11]; + u8 filler_2A[2]; u8 unk_2C; u8 filler_2D[3]; u8 unk_30; @@ -109,7 +112,12 @@ struct DodrioBerryPickingStruct // align 2 /*0x012C*/ u32 unk_012C; /*0x0130*/ u32 unk_0130[5]; - /*0x0144*/ u8 filler_0144[0x1C]; + /*0x0144*/ u8 unk_0144; + /*0x0145*/ u8 filler_0145[3]; + /*0x0148*/ u8 unk_0148[11]; + /*0x0153*/ u8 filler_0153[1]; + /*0x0154*/ u8 unk_0154; + /*0x0155*/ u8 filler_0155[11]; /*0x0160*/ struct DodrioBerryPickingSubstruct_0160 unk_0160; /*0x318C*/ struct DodrioBerryPickingSubstruct_318C unk_318C[5]; /*0x31A0*/ struct DodrioBerryPickingSubstruct_31A0 unk_31A0[5]; @@ -165,6 +173,8 @@ void sub_802671C(void); void sub_8026AF4(void); void sub_8026B28(void); void sub_8026B5C(u8, u8*, u8*); +u32 sub_8026BB8(void); +void sub_8026C28(void); bool32 sub_8026C50(void); bool32 sub_8026C90(void); void sub_80272E8(void); @@ -175,10 +185,16 @@ u8 sub_8027518(u8); void sub_8027554(void); void sub_8027608(void); u32 sub_8027748(void); +void sub_8027DD0(u8); +u32 sub_8027E30(struct DodrioBerryPickingSubstruct_31A0 *, u8 *, u8 *, u8 *, u8 *, u8 *, u8, u32, u32); u32 sub_8028164(u32 unused, struct DodrioBerryPickingSubstruct_31A0 *, u8 *, u8 *, u8 *, u8 *, u8 *, u8 *, u32 *, u32 *); +void sub_80282EC(u8); u32 sub_8028318(u8, u8 *); +void sub_8028350(u8); +bool32 sub_8028374(u8); void sub_80283A8(void); void sub_8028408(struct DodrioBerryPickingSubstruct_318C *, u8, u8, u8); +void sub_80284CC(u8); void sub_8028504(u8); void sub_8028614(u8); void sub_802868C(u8, u8); @@ -1099,3 +1115,202 @@ void sub_80259FC(void) } } } + +void sub_8025C0C(void) +{ + u8 i; + u8 r6 = gUnknown_02022C98->unk_0024; + + gUnknown_02022C98->unk_31A0[0].unk_10 = sub_8028164(0, &gUnknown_02022C98->unk_31A0[0], &gUnknown_02022C98->unk_31A0[0].unk_2C, &gUnknown_02022C98->unk_31A0[1].unk_2C, &gUnknown_02022C98->unk_31A0[2].unk_2C, &gUnknown_02022C98->unk_31A0[3].unk_2C, &gUnknown_02022C98->unk_31A0[4].unk_2C, &gUnknown_02022C98->unk_0040, &gUnknown_02022C98->unk_0120, &gUnknown_02022C98->unk_012C); + gUnknown_02022C98->unk_0128 = 1; + + for (i = 1; i < r6; i++) + { + if (sub_8028374(i) != 0) + { + gUnknown_02022C98->unk_0130[i] = 1; + gUnknown_02022C98->unk_0128 = 0; + } + } + if (++gUnknown_02022C98->unk_0124 >= 60) + { + if (gUnknown_02022C98->unk_0128 != 0) + { + sub_8011AC8(); + gUnknown_02022C98->unk_0124 = 0; + } + else if (gUnknown_02022C98->unk_0124 > 70) + { + sub_8011AC8(); + gUnknown_02022C98->unk_0124 = 0; + } + } +} + +void sub_8025D04(void) +{ + switch (gUnknown_02022C98->unk_0018) + { + case 3: + if (sub_8026BB8() == 1) + { + sub_8026C28(); + gUnknown_02022C98->unk_011C = 1; + } + break; + case 4: + sub_80259FC(); + break; + case 11: + sub_8025C0C(); + break; + } +} + +void sub_8025D50(void) +{ + switch (gUnknown_02022C98->unk_0018) + { + case 4: + sub_8027E30(&gUnknown_02022C98->unk_32CC, &gUnknown_02022C98->unk_31A0[0].unk_2C, &gUnknown_02022C98->unk_31A0[1].unk_2C, &gUnknown_02022C98->unk_31A0[2].unk_2C, &gUnknown_02022C98->unk_31A0[3].unk_2C, &gUnknown_02022C98->unk_31A0[4].unk_2C, gUnknown_02022C98->unk_0040, gUnknown_02022C98->unk_0120, gUnknown_02022C98->unk_012C); + break; + case 11: + sub_8027E30(&gUnknown_02022C98->unk_32CC, &gUnknown_02022C98->unk_31A0[0].unk_2C, &gUnknown_02022C98->unk_31A0[1].unk_2C, &gUnknown_02022C98->unk_31A0[2].unk_2C, &gUnknown_02022C98->unk_31A0[3].unk_2C, &gUnknown_02022C98->unk_31A0[4].unk_2C, gUnknown_02022C98->unk_0040, gUnknown_02022C98->unk_0120, gUnknown_02022C98->unk_012C); + break; + } +} + +void sub_8025E0C(void) +{ + switch (gUnknown_02022C98->unk_0018) + { + case 4: + sub_8028164(gUnknown_02022C98->multiplayerId, &gUnknown_02022C98->unk_31A0[gUnknown_02022C98->multiplayerId], &gUnknown_02022C98->unk_31A0[0].unk_2C, &gUnknown_02022C98->unk_31A0[1].unk_2C, &gUnknown_02022C98->unk_31A0[2].unk_2C, &gUnknown_02022C98->unk_31A0[3].unk_2C, &gUnknown_02022C98->unk_31A0[4].unk_2C, &gUnknown_02022C98->unk_0040, &gUnknown_02022C98->unk_0120, &gUnknown_02022C98->unk_012C); + break; + case 11: + sub_8028164(gUnknown_02022C98->multiplayerId, &gUnknown_02022C98->unk_31A0[gUnknown_02022C98->multiplayerId], &gUnknown_02022C98->unk_31A0[0].unk_2C, &gUnknown_02022C98->unk_31A0[1].unk_2C, &gUnknown_02022C98->unk_31A0[2].unk_2C, &gUnknown_02022C98->unk_31A0[3].unk_2C, &gUnknown_02022C98->unk_31A0[4].unk_2C, &gUnknown_02022C98->unk_0040, &gUnknown_02022C98->unk_0120, &gUnknown_02022C98->unk_012C); + break; + } +} + +void sub_8025ED8(void) +{ + switch (gUnknown_02022C98->unk_0018) + { + case 3: + sub_8027DD0(1); + gUnknown_02022C98->unk_011C = 1; + break; + case 4: + if (gUnknown_02022C98->unk_32CC.unk_2C != 0) + { + sub_80282EC(gUnknown_02022C98->unk_32CC.unk_2C); + } + break; + case 11: + if (gUnknown_02022C98->unk_0120 == 0 && gUnknown_02022C98->unk_012C == 0) + { + sub_8028350(1); + } + break; + } +} + +void sub_8025F48(void) +{ + if (gUnknown_02022C98->unk_31A0[gUnknown_02022C98->multiplayerId].unk_2C == 0) + { + if (!IsSEPlaying()) + { + gUnknown_02022C98->unk_0144 = 0; + } + } + else if (gUnknown_02022C98->unk_31A0[gUnknown_02022C98->multiplayerId].unk_30 == 1) + { + if (gUnknown_02022C98->unk_0144 == 0) + { + m4aSongNumStop(SE_SEIKAI); + PlaySE(SE_SEIKAI); + gUnknown_02022C98->unk_0144 = 1; + } + } + else if (gUnknown_02022C98->unk_31A0[gUnknown_02022C98->multiplayerId].unk_34 == 1) + { + if (gUnknown_02022C98->unk_0144 == 0 && !IsSEPlaying()) + { + PlaySE(SE_BOO); + sub_80284CC(1); + gUnknown_02022C98->unk_0144 = 1; + } + } + + if (gUnknown_02022C98->unk_0154 == 0 && gUnknown_02022C98->unk_0040 >= 10) + { + StopMapMusic(); + gUnknown_02022C98->unk_0154 = 1; + } + else if (gUnknown_02022C98->unk_0154 == 1) + { + PlayFanfareByFanfareNum(11); // MUS_ME_ZANNEN + gUnknown_02022C98->unk_0154 = 2; + } +} + +void sub_8026044(void) +{ + u8 r8 = gUnknown_02022C98->unk_0044; + u8 r7 = gUnknown_02022C98->unk_0048; + u8 r4; + if (gUnknown_02022C98->unk_31A0[gUnknown_02022C98->multiplayerId].unk_2C == 0) + { + if (gUnknown_02022C98->unk_31A0[gUnknown_02022C98->multiplayerId].unk_30 != 1 && gUnknown_02022C98->unk_31A0[gUnknown_02022C98->multiplayerId].unk_34 != 1) + { + gUnknown_02022C98->unk_0144 = 0; + } + } + else if (gUnknown_02022C98->unk_31A0[gUnknown_02022C98->multiplayerId].unk_30 == 1) + { + if (gUnknown_02022C98->unk_0144 == 0) + { + m4aSongNumStop(SE_SEIKAI); + PlaySE(SE_SEIKAI); + gUnknown_02022C98->unk_0144 = 1; + } + } + else if (gUnknown_02022C98->unk_31A0[gUnknown_02022C98->multiplayerId].unk_34 == 1) + { + if (gUnknown_02022C98->unk_0144 == 0 && !IsSEPlaying()) + { + PlaySE(SE_BOO); + sub_80284CC(1); + gUnknown_02022C98->unk_0144 = 1; + } + } + for (r4 = r8; r4 < r7; r4++) + { + struct DodrioBerryPickingSubstruct_31A0 * ptr = &gUnknown_02022C98->unk_31A0[gUnknown_02022C98->multiplayerId]; + u8 * r1 = ptr->unk_14; + if (ptr->unk_1F[r4] >= 10) + { + if (gUnknown_02022C98->unk_0148[r4] == 0) + { + PlaySE(SE_FUUSEN1 + r1[r4]); + gUnknown_02022C98->unk_0148[r4] = 1; + } + } + else + { + gUnknown_02022C98->unk_0148[r4] = 0; + } + } + if (gUnknown_02022C98->unk_0154 == 0 && gUnknown_02022C98->unk_0040 >= 10) + { + StopMapMusic(); + gUnknown_02022C98->unk_0154 = 1; + } + else if (gUnknown_02022C98->unk_0154 == 1) + { + PlayFanfareByFanfareNum(11); // MUS_ME_ZANNEN + gUnknown_02022C98->unk_0154 = 2; + } +} From 03e58d7dc9759822854bbe30ca067286e41f67c3 Mon Sep 17 00:00:00 2001 From: scnorton Date: Mon, 25 Mar 2019 18:08:25 -0400 Subject: [PATCH 10/13] through sub_80262C0 --- asm/dodrio_berry_picking.s | 182 ------ src/dodrio_berry_picking.c | 1088 +++++++++++++++++++----------------- 2 files changed, 585 insertions(+), 685 deletions(-) diff --git a/asm/dodrio_berry_picking.s b/asm/dodrio_berry_picking.s index cb3b042d9..296f8b006 100755 --- a/asm/dodrio_berry_picking.s +++ b/asm/dodrio_berry_picking.s @@ -5,188 +5,6 @@ .text - thumb_func_start sub_80261CC -sub_80261CC: @ 80261CC - push {lr} - bl RunTasks - bl AnimateSprites - bl BuildOamBuffer - bl UpdatePaletteFade - pop {r0} - bx r0 - thumb_func_end sub_80261CC - - thumb_func_start sub_80261E4 -sub_80261E4: @ 80261E4 - push {lr} - bl TransferPlttBuffer - bl LoadOam - bl ProcessSpriteCopyRequests - pop {r0} - bx r0 - thumb_func_end sub_80261E4 - - thumb_func_start sub_80261F8 -sub_80261F8: @ 80261F8 - push {r4,lr} - adds r4, r0, 0 - adds r0, r1, 0 - bl IsMonShiny - strb r0, [r4] - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_80261F8 - - thumb_func_start sub_802620C -sub_802620C: @ 802620C - push {lr} - lsls r1, 24 - lsrs r1, 24 - bl CreateTask - pop {r0} - bx r0 - thumb_func_end sub_802620C - - thumb_func_start sub_802621C -sub_802621C: @ 802621C - push {lr} - movs r1, 0x1 - bl CreateTask - ldr r1, =gUnknown_02022C98 - ldr r3, [r1] - movs r2, 0 - strb r0, [r3, 0x4] - ldr r0, [r1] - strb r2, [r0, 0x10] - ldr r0, [r1] - strb r2, [r0, 0xC] - ldr r0, [r1] - strb r2, [r0, 0x14] - pop {r0} - bx r0 - .pool - thumb_func_end sub_802621C - - thumb_func_start sub_8026240 -sub_8026240: @ 8026240 - push {r4,lr} - ldr r2, =gUnknown_02022C98 - ldr r1, [r2] - ldrb r3, [r1, 0x18] - movs r4, 0 - strb r3, [r1, 0x1C] - ldr r1, [r2] - strb r0, [r1, 0x18] - ldr r0, [r2] - strb r4, [r0, 0x10] - ldr r0, [r2] - strb r4, [r0, 0x14] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8026240 - - thumb_func_start sub_8026264 -sub_8026264: @ 8026264 - push {r4,lr} - ldr r3, =gUnknown_02022C98 - ldr r1, [r3] - ldrb r0, [r1, 0x14] - lsrs r2, r0, 2 - adds r0, 0x1 - strb r0, [r1, 0x14] - cmp r2, 0 - beq _080262B8 - ldr r3, [r3] - ldrb r0, [r3, 0x14] - movs r1, 0x3 - ands r0, r1 - cmp r0, 0 - bne _080262B8 - ldr r1, =gUnknown_082F7A94 - adds r0, r3, 0 - adds r0, 0x24 - ldrb r0, [r0] - subs r0, 0x1 - adds r0, r1 - ldrb r0, [r0] - cmp r2, r0 - bcc _080262A0 - movs r0, 0x1 - b _080262BA - .pool -_080262A0: - lsls r4, r2, 3 - adds r1, r4, 0 - movs r0, 0x14 - bl SetGpuReg - negs r4, r4 - lsls r4, 16 - lsrs r4, 16 - movs r0, 0x18 - adds r1, r4, 0 - bl SetGpuReg -_080262B8: - movs r0, 0 -_080262BA: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8026264 - - thumb_func_start sub_80262C0 -sub_80262C0: @ 80262C0 - push {r4-r7,lr} - mov r7, r8 - push {r7} - ldr r2, =gUnknown_02022C98 - ldr r0, [r2] - adds r1, r0, 0 - adds r1, 0x44 - adds r0, 0x48 - ldrb r5, [r0] - ldrb r1, [r1] - cmp r1, r5 - bcs _0802630C - mov r8, r2 - ldr r0, =0x000032e0 - mov r12, r0 - movs r7, 0 - movs r6, 0x1 -_080262E2: - mov r2, r8 - ldr r0, [r2] - mov r2, r12 - adds r4, r0, r2 - ldr r2, =0x000032eb - adds r0, r2 - adds r2, r0, r1 - movs r3, 0 - adds r0, r1, 0 - ands r0, r6 - cmp r0, 0 - bne _080262FC - movs r3, 0x1 -_080262FC: - strb r3, [r2] - adds r0, r4, r1 - strb r7, [r0] - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, r5 - bcc _080262E2 -_0802630C: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80262C0 - thumb_func_start sub_8026324 sub_8026324: @ 8026324 push {r4-r7,lr} diff --git a/src/dodrio_berry_picking.c b/src/dodrio_berry_picking.c index 922b551d9..1e698fefb 100644 --- a/src/dodrio_berry_picking.c +++ b/src/dodrio_berry_picking.c @@ -3,6 +3,7 @@ #include "palette.h" #include "window.h" #include "bg.h" +#include "gpu_regs.h" #include "link.h" #include "link_rfu.h" #include "task.h" @@ -221,6 +222,8 @@ u8 sub_802A794(void); extern void (*const gUnknown_082F7AC4[])(void); extern void (*const gUnknown_082F7AF4[])(void); +extern const u8 gUnknown_082F7A94[]; + void sub_802493C(u16 a0, void (*a1)(void)) { gUnknown_03000DB0 = FALSE; @@ -314,70 +317,70 @@ void sub_8024BC8(u8 taskId) switch (gUnknown_02022C98->unk_000C) { - case 0: - SetVBlankCallback(NULL); - sub_802620C(sub_8025910, 4); + case 0: + SetVBlankCallback(NULL); + sub_802620C(sub_8025910, 4); + gUnknown_02022C98->unk_000C++; + break; + case 1: + if (!FuncIsActiveTask(sub_8025910)) + { + sub_8029274(&gUnknown_02022C98->unk_0160); gUnknown_02022C98->unk_000C++; - break; - case 1: - if (!FuncIsActiveTask(sub_8025910)) - { - sub_8029274(&gUnknown_02022C98->unk_0160); - gUnknown_02022C98->unk_000C++; - } - break; - case 2: - if (!sub_802A770()) - { - sub_8010434(); - gUnknown_02022C98->unk_000C++; - } - break; - case 3: - if (IsLinkTaskFinished()) - { - if (gReceivedRemoteLinkPlayers != 0) - { - sub_800E0E8(); - CreateWirelessStatusIndicatorSprite(0, 0); - } - gUnknown_02022C98->unk_000C++; - } - break; - case 4: - r5 = gUnknown_02022C98->unk_0024; - sub_80283A8(); - for (r4 = 0; r4 < r5; r4++) - { - sub_8028408(&gUnknown_02022C98->unk_318C[gUnknown_02022C98->unk_0034[r4]], r4, gUnknown_02022C98->unk_0034[r4], gUnknown_02022C98->unk_0024); - } - sub_802868C(0, gUnknown_02022C98->unk_0024); + } + break; + case 2: + if (!sub_802A770()) + { + sub_8010434(); gUnknown_02022C98->unk_000C++; - break; - case 5: - sub_8028A34(); - sub_8028A88(); - sub_8028D44(); - sub_8028734(); - gUnknown_02022C98->unk_000C++; - break; - case 6: - BlendPalettes(0xFFFFFFFF, 0x10, 0x00); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); - SetVBlankCallback(sub_80261E4); - gUnknown_02022C98->unk_000C++; - break; - case 7: - UpdatePaletteFade(); - if (!gPaletteFade.active) + } + break; + case 3: + if (IsLinkTaskFinished()) + { + if (gReceivedRemoteLinkPlayers != 0) { - gUnknown_02022C98->unk_000C++; + sub_800E0E8(); + CreateWirelessStatusIndicatorSprite(0, 0); } - break; - default: - DestroyTask(taskId); - sub_802621C(sub_802589C); - break; + gUnknown_02022C98->unk_000C++; + } + break; + case 4: + r5 = gUnknown_02022C98->unk_0024; + sub_80283A8(); + for (r4 = 0; r4 < r5; r4++) + { + sub_8028408(&gUnknown_02022C98->unk_318C[gUnknown_02022C98->unk_0034[r4]], r4, gUnknown_02022C98->unk_0034[r4], gUnknown_02022C98->unk_0024); + } + sub_802868C(0, gUnknown_02022C98->unk_0024); + gUnknown_02022C98->unk_000C++; + break; + case 5: + sub_8028A34(); + sub_8028A88(); + sub_8028D44(); + sub_8028734(); + gUnknown_02022C98->unk_000C++; + break; + case 6: + BlendPalettes(0xFFFFFFFF, 0x10, 0x00); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); + SetVBlankCallback(sub_80261E4); + gUnknown_02022C98->unk_000C++; + break; + case 7: + UpdatePaletteFade(); + if (!gPaletteFade.active) + { + gUnknown_02022C98->unk_000C++; + } + break; + default: + DestroyTask(taskId); + sub_802621C(sub_802589C); + break; } } @@ -407,15 +410,15 @@ void sub_8024DBC(void) { switch (gUnknown_02022C98->unk_0010) { - case 0: - sub_8028504(1); - sub_80292E0(1); - gUnknown_02022C98->unk_0010++; - break; - case 1: - if (!sub_802A770()) - sub_8026240(1); - break; + case 0: + sub_8028504(1); + sub_80292E0(1); + gUnknown_02022C98->unk_0010++; + break; + case 1: + if (!sub_802A770()) + sub_8026240(1); + break; } } @@ -437,40 +440,40 @@ void sub_8024E38(void) { switch (gUnknown_02022C98->unk_0010) { - case 0: - sub_802EB24(7, 8, 120, 80, 0); + case 0: + sub_802EB24(7, 8, 120, 80, 0); + gUnknown_02022C98->unk_0010++; + break; + case 1: + sub_8010434(); + gUnknown_02022C98->unk_0010++; + break; + case 2: + if (IsLinkTaskFinished()) + { gUnknown_02022C98->unk_0010++; - break; - case 1: + gUnknown_02022C98->unk_0030 = 0; + } + break; + case 3: + if (!sub_802EB84()) + { + gUnknown_02022C98->unk_0010++; + } + break; + case 4: + if (++gUnknown_02022C98->unk_0030 > 5) + { sub_8010434(); gUnknown_02022C98->unk_0010++; - break; - case 2: - if (IsLinkTaskFinished()) - { - gUnknown_02022C98->unk_0010++; - gUnknown_02022C98->unk_0030 = 0; - } - break; - case 3: - if (!sub_802EB84()) - { - gUnknown_02022C98->unk_0010++; - } - break; - case 4: - if (++gUnknown_02022C98->unk_0030 > 5) - { - sub_8010434(); - gUnknown_02022C98->unk_0010++; - } - break; - case 5: - if (IsLinkTaskFinished()) - { - sub_8026240(3); - } - break; + } + break; + case 5: + if (IsLinkTaskFinished()) + { + sub_8026240(3); + } + break; } } @@ -620,37 +623,37 @@ void sub_8025198(void) { switch (gUnknown_02022C98->unk_0010) { - case 0: - if (SendBlock(0, gUnknown_02022C98->unk_004A, sizeof(gUnknown_02022C98->unk_004A))) - { - gUnknown_02022C98->unk_0008 = 0; - gUnknown_02022C98->unk_0010++; - } - break; - case 1: - if (IsLinkTaskFinished()) - { - gUnknown_02022C98->unk_0010++; - } - break; - case 2: - if (sub_8025170()) - { - gUnknown_02022C98->unk_0008 = gUnknown_02022C98->unk_0024; - } - if (gUnknown_02022C98->unk_0008 >= gUnknown_02022C98->unk_0024) - { - gUnknown_02022C98->unk_0014++; - gUnknown_02022C98->unk_0010++; - } - break; - default: - if (WaitFanfare(TRUE)) - { - sub_8026240(6); - FadeOutAndPlayNewMapMusic(MUS_RG_WIN_YASEI, 4); - } - break; + case 0: + if (SendBlock(0, gUnknown_02022C98->unk_004A, sizeof(gUnknown_02022C98->unk_004A))) + { + gUnknown_02022C98->unk_0008 = 0; + gUnknown_02022C98->unk_0010++; + } + break; + case 1: + if (IsLinkTaskFinished()) + { + gUnknown_02022C98->unk_0010++; + } + break; + case 2: + if (sub_8025170()) + { + gUnknown_02022C98->unk_0008 = gUnknown_02022C98->unk_0024; + } + if (gUnknown_02022C98->unk_0008 >= gUnknown_02022C98->unk_0024) + { + gUnknown_02022C98->unk_0014++; + gUnknown_02022C98->unk_0010++; + } + break; + default: + if (WaitFanfare(TRUE)) + { + sub_8026240(6); + FadeOutAndPlayNewMapMusic(MUS_RG_WIN_YASEI, 4); + } + break; } } @@ -659,37 +662,37 @@ void sub_8025230(void) u8 i; switch (gUnknown_02022C98->unk_0010) { - case 0: - if (SendBlock(0, gUnknown_02022C98->unk_004A[gUnknown_02022C98->unk_0014], - sizeof(gUnknown_02022C98->unk_004A))) { - gUnknown_02022C98->unk_0008 = 0; - gUnknown_02022C98->unk_0010++; + case 0: + if (SendBlock(0, gUnknown_02022C98->unk_004A[gUnknown_02022C98->unk_0014], + sizeof(gUnknown_02022C98->unk_004A))) { + gUnknown_02022C98->unk_0008 = 0; + gUnknown_02022C98->unk_0010++; + } + break; + case 1: + if (IsLinkTaskFinished()) { + gUnknown_02022C98->unk_0010++; + } + break; + case 2: + if (sub_8025170()) { + for (i = 0; i < gUnknown_02022C98->unk_0024; i++) { + memcpy(gUnknown_02022C98->unk_004A, gBlockRecvBuffer, sizeof(gUnknown_02022C98->unk_004A)); + gUnknown_02022C98->unk_0008 = gUnknown_02022C98->unk_0024; } - break; - case 1: - if (IsLinkTaskFinished()) { - gUnknown_02022C98->unk_0010++; - } - break; - case 2: - if (sub_8025170()) { - for (i = 0; i < gUnknown_02022C98->unk_0024; i++) { - memcpy(gUnknown_02022C98->unk_004A, gBlockRecvBuffer, sizeof(gUnknown_02022C98->unk_004A)); - gUnknown_02022C98->unk_0008 = gUnknown_02022C98->unk_0024; - } - } - if (gUnknown_02022C98->unk_0008 >= gUnknown_02022C98->unk_0024) { - gUnknown_02022C98->unk_0014++; - gUnknown_02022C98->unk_0010++; - } - break; - default: - if (WaitFanfare(TRUE)) { - gUnknown_02022C98->unk_0114 = gUnknown_02022C98->unk_004A[gUnknown_02022C98->multiplayerId][5]; - sub_8026240(6); - FadeOutAndPlayNewMapMusic(MUS_RG_WIN_YASEI, 4); - } - break; + } + if (gUnknown_02022C98->unk_0008 >= gUnknown_02022C98->unk_0024) { + gUnknown_02022C98->unk_0014++; + gUnknown_02022C98->unk_0010++; + } + break; + default: + if (WaitFanfare(TRUE)) { + gUnknown_02022C98->unk_0114 = gUnknown_02022C98->unk_004A[gUnknown_02022C98->multiplayerId][5]; + sub_8026240(6); + FadeOutAndPlayNewMapMusic(MUS_RG_WIN_YASEI, 4); + } + break; } } @@ -700,58 +703,58 @@ void sub_8025324(void) switch (gUnknown_02022C98->unk_0010) { - case 0: - sub_802749C(); - sub_80289E8(1); - sub_8028DFC(); - sub_8028EC8(1); - sub_80292E0(2); + case 0: + sub_802749C(); + sub_80289E8(1); + sub_8028DFC(); + sub_8028EC8(1); + sub_80292E0(2); + gUnknown_02022C98->unk_0010++; + break; + case 1: + if (!sub_802A770()) + { + sub_80292E0(5); gUnknown_02022C98->unk_0010++; - break; - case 1: - if (!sub_802A770()) + } + break; + case 2: + sp00 = sub_802A794(); + if (SendBlock(0, &sp00, sizeof(sp00))) + { + gUnknown_02022C98->unk_0010++; + } + break; + case 3: + if (IsLinkTaskFinished()) + { + gUnknown_02022C98->unk_0010++; + gUnknown_02022C98->unk_0008 = 0; + } + break; + case 4: + if (sub_8025170()) + { + for (i = 0; i < gUnknown_02022C98->unk_0024; i++) { - sub_80292E0(5); + *(gUnknown_02022C98->unk_010C + i) = *(u8 *)gBlockRecvBuffer[i]; + gUnknown_02022C98->unk_0008 = gUnknown_02022C98->unk_0024; + } + } + if (gUnknown_02022C98->unk_0008 >= gUnknown_02022C98->unk_0024) { + if (++gUnknown_02022C98->unk_0014 >= 120) + { + sub_80292E0(6); gUnknown_02022C98->unk_0010++; } - break; - case 2: - sp00 = sub_802A794(); - if (SendBlock(0, &sp00, sizeof(sp00))) - { - gUnknown_02022C98->unk_0010++; - } - break; - case 3: - if (IsLinkTaskFinished()) - { - gUnknown_02022C98->unk_0010++; - gUnknown_02022C98->unk_0008 = 0; - } - break; - case 4: - if (sub_8025170()) - { - for (i = 0; i < gUnknown_02022C98->unk_0024; i++) - { - *(gUnknown_02022C98->unk_010C + i) = *(u8 *)gBlockRecvBuffer[i]; - gUnknown_02022C98->unk_0008 = gUnknown_02022C98->unk_0024; - } - } - if (gUnknown_02022C98->unk_0008 >= gUnknown_02022C98->unk_0024) { - if (++gUnknown_02022C98->unk_0014 >= 120) - { - sub_80292E0(6); - gUnknown_02022C98->unk_0010++; - } - } - break; - default: - if (!sub_802A770()) - { - sub_8026240(7); - } - break; + } + break; + default: + if (!sub_802A770()) + { + sub_8026240(7); + } + break; } } @@ -762,88 +765,88 @@ void sub_8025470(void) switch (gUnknown_02022C98->unk_0010) { - case 0: - if (sub_8027748() >= 3000) - { - sub_80292E0(4); - } + case 0: + if (sub_8027748() >= 3000) + { + sub_80292E0(4); + } + gUnknown_02022C98->unk_0010++; + break; + case 1: + if (!sub_802A770()) + { + sub_80292E0(3); gUnknown_02022C98->unk_0010++; - break; - case 1: - if (!sub_802A770()) - { - sub_80292E0(3); - gUnknown_02022C98->unk_0010++; - } - break; - case 2: - sub_8028FCC(); - sub_80272E8(); + } + break; + case 2: + sub_8028FCC(); + sub_80272E8(); + gUnknown_02022C98->unk_0010++; + break; + case 3: + if ((sp0 = sub_802A794()) != 0) + { gUnknown_02022C98->unk_0010++; - break; - case 3: - if ((sp0 = sub_802A794()) != 0) + } + break; + case 4: + if (!sub_802A770()) + { + sub_80292E0(5); + gUnknown_02022C98->unk_0010++; + } + break; + case 5: + sp0 = sub_802A794(); + if (SendBlock(0, &sp0, sizeof(sp0))) + { + gUnknown_02022C98->unk_0008 = 0; + gUnknown_02022C98->unk_0010++; + } + break; + case 6: + if (IsLinkTaskFinished()) + { + gUnknown_02022C98->unk_0010++; + } + break; + case 7: + if (sub_8025170()) + { + for (i = 0; i < gUnknown_02022C98->unk_0024; i++) { + *(gUnknown_02022C98->unk_010C + i) = *(u8 *)gBlockRecvBuffer[i]; + gUnknown_02022C98->unk_0008 = gUnknown_02022C98->unk_0024; + } + } + if (gUnknown_02022C98->unk_0008 >= gUnknown_02022C98->unk_0024) { + if (++gUnknown_02022C98->unk_0014 >= 120) + { + sub_8027608(); + sub_80292E0(6); gUnknown_02022C98->unk_0010++; } - break; - case 4: - if (!sub_802A770()) + } + else + { + sub_8027554(); + } + break; + default: + if (!sub_802A770()) + { + for (i = 0; i < gUnknown_02022C98->unk_0024; i++) { - sub_80292E0(5); - gUnknown_02022C98->unk_0010++; - } - break; - case 5: - sp0 = sub_802A794(); - if (SendBlock(0, &sp0, sizeof(sp0))) - { - gUnknown_02022C98->unk_0008 = 0; - gUnknown_02022C98->unk_0010++; - } - break; - case 6: - if (IsLinkTaskFinished()) - { - gUnknown_02022C98->unk_0010++; - } - break; - case 7: - if (sub_8025170()) - { - for (i = 0; i < gUnknown_02022C98->unk_0024; i++) + if (gUnknown_02022C98->unk_010C[i] == 2) { - *(gUnknown_02022C98->unk_010C + i) = *(u8 *)gBlockRecvBuffer[i]; - gUnknown_02022C98->unk_0008 = gUnknown_02022C98->unk_0024; + sub_8026240(8); + return; } } - if (gUnknown_02022C98->unk_0008 >= gUnknown_02022C98->unk_0024) { - if (++gUnknown_02022C98->unk_0014 >= 120) - { - sub_8027608(); - sub_80292E0(6); - gUnknown_02022C98->unk_0010++; - } - } - else - { - sub_8027554(); - } - break; - default: - if (!sub_802A770()) - { - for (i = 0; i < gUnknown_02022C98->unk_0024; i++) - { - if (gUnknown_02022C98->unk_010C[i] == 2) - { - sub_8026240(8); - return; - } - } - sub_8026240(10); - } - break; + sub_8026240(10); + } + break; } } @@ -851,29 +854,29 @@ void sub_8025644(void) { switch (gUnknown_02022C98->unk_0010) { - case 0: - sub_800AC34(); - sub_80292E0(7); + case 0: + sub_800AC34(); + sub_80292E0(7); + gUnknown_02022C98->unk_0010++; + break; + case 1: + if (!sub_802A770()) + { gUnknown_02022C98->unk_0010++; - break; - case 1: - if (!sub_802A770()) - { - gUnknown_02022C98->unk_0010++; - } - break; - case 2: - if (sub_802A794() == 5) - { - gUnknown_02022C98->unk_0010++; - } - break; - default: - if (gReceivedRemoteLinkPlayers == 0) - { - sub_8026240(9); - } - break; + } + break; + case 2: + if (sub_802A794() == 5) + { + gUnknown_02022C98->unk_0010++; + } + break; + default: + if (gReceivedRemoteLinkPlayers == 0) + { + sub_8026240(9); + } + break; } } @@ -881,35 +884,35 @@ void sub_80256AC(void) { switch (gUnknown_02022C98->unk_0010) { - case 0: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + case 0: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gUnknown_02022C98->unk_0010++; + break; + case 1: + UpdatePaletteFade(); + if (!gPaletteFade.active) + { gUnknown_02022C98->unk_0010++; - break; - case 1: - UpdatePaletteFade(); - if (!gPaletteFade.active) - { - gUnknown_02022C98->unk_0010++; - } - break; - case 2: - sub_8028B80(); - sub_80287E4(); - sub_8028614(gUnknown_02022C98->unk_0024); - sub_8028E84(); - gUnknown_03000DB0 = TRUE; - sub_80292E0(8); - gUnknown_02022C98->unk_0010++; - break; - default: - if (!sub_802A770()) - { - SetMainCallback2(gUnknown_02022C98->savedCallback); - DestroyTask(gUnknown_02022C98->unk_0004); - Free(gUnknown_02022C98); - FreeAllWindowBuffers(); - } - break; + } + break; + case 2: + sub_8028B80(); + sub_80287E4(); + sub_8028614(gUnknown_02022C98->unk_0024); + sub_8028E84(); + gUnknown_03000DB0 = TRUE; + sub_80292E0(8); + gUnknown_02022C98->unk_0010++; + break; + default: + if (!sub_802A770()) + { + SetMainCallback2(gUnknown_02022C98->savedCallback); + DestroyTask(gUnknown_02022C98->unk_0004); + Free(gUnknown_02022C98); + FreeAllWindowBuffers(); + } + break; } } @@ -917,62 +920,62 @@ void sub_8025758(void) { switch (gUnknown_02022C98->unk_0010) { - case 0: - sub_80292E0(9); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + case 0: + sub_80292E0(9); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gUnknown_02022C98->unk_0010++; + break; + case 1: + UpdatePaletteFade(); + if (!gPaletteFade.active) + { gUnknown_02022C98->unk_0010++; - break; - case 1: - UpdatePaletteFade(); - if (!gPaletteFade.active) - { - gUnknown_02022C98->unk_0010++; - } - break; - case 2: - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); - ChangeBgX(2, 0, 0); - ChangeBgY(2, 0, 0); - ChangeBgX(3, 0, 0); - ChangeBgY(3, 0, 0); + } + break; + case 2: + ChangeBgX(0, 0, 0); + ChangeBgY(0, 0, 0); + ChangeBgX(1, 0, 0); + ChangeBgY(1, 0, 0); + ChangeBgX(2, 0, 0); + ChangeBgY(2, 0, 0); + ChangeBgX(3, 0, 0); + ChangeBgY(3, 0, 0); + gUnknown_02022C98->unk_0010++; + break; + case 3: + StopMapMusic(); + gUnknown_02022C98->unk_0010++; + break; + case 4: + PlayNewMapMusic(MUS_RG_KINOMIKUI); + sub_8028E4C(); + gUnknown_02022C98->unk_0010++; + break; + case 5: + BlendPalettes(0xFFFFFFFF, 16, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); + gUnknown_02022C98->unk_0010++; + break; + case 6: + UpdatePaletteFade(); + if (!gPaletteFade.active) + { gUnknown_02022C98->unk_0010++; - break; - case 3: - StopMapMusic(); - gUnknown_02022C98->unk_0010++; - break; - case 4: - PlayNewMapMusic(MUS_RG_KINOMIKUI); - sub_8028E4C(); - gUnknown_02022C98->unk_0010++; - break; - case 5: - BlendPalettes(0xFFFFFFFF, 16, 0); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); - gUnknown_02022C98->unk_0010++; - break; - case 6: - UpdatePaletteFade(); - if (!gPaletteFade.active) - { - gUnknown_02022C98->unk_0010++; - } - break; - default: - DestroyTask(gUnknown_02022C98->unk_0004); - sub_802621C(sub_802589C); - sub_802903C(); - sub_8024A30(gUnknown_02022C98); - if (gReceivedRemoteLinkPlayers == 0) - { - gUnknown_02022C98->unk_0024 = 1; - } - sub_80273F0(); - sub_8028EC8(0); - break; + } + break; + default: + DestroyTask(gUnknown_02022C98->unk_0004); + sub_802621C(sub_802589C); + sub_802903C(); + sub_8024A30(gUnknown_02022C98); + if (gReceivedRemoteLinkPlayers == 0) + { + gUnknown_02022C98->unk_0024 = 1; + } + sub_80273F0(); + sub_8028EC8(0); + break; } } @@ -980,33 +983,33 @@ void sub_802589C(u8 taskId) { switch (gUnknown_02022C98->unk_0010) { - case 0: - if (sub_8026264() == 1) - { - gUnknown_02022C98->unk_0010++; - } - break; - case 1: - sub_80286E4(); + case 0: + if (sub_8026264() == 1) + { gUnknown_02022C98->unk_0010++; - break; - case 2: - if (sub_8028828() == 1) - { - gUnknown_02022C98->unk_0010++; - } - break; - default: - if (gUnknown_02022C98->unk_0020 != 0) - { - sub_802621C(sub_8024D4C); - } - else - { - sub_802621C(sub_8024D84); - } - DestroyTask(taskId); - break; + } + break; + case 1: + sub_80286E4(); + gUnknown_02022C98->unk_0010++; + break; + case 2: + if (sub_8028828() == 1) + { + gUnknown_02022C98->unk_0010++; + } + break; + default: + if (gUnknown_02022C98->unk_0020 != 0) + { + sub_802621C(sub_8024D4C); + } + else + { + sub_802621C(sub_8024D84); + } + DestroyTask(taskId); + break; } } @@ -1017,35 +1020,35 @@ void sub_8025910(u8 taskId) switch (data[0]) { - case 0: - if (SendBlock(0, &gUnknown_02022C98->unk_318C[gUnknown_02022C98->multiplayerId].isShiny, sizeof(gUnknown_02022C98->unk_318C[gUnknown_02022C98->multiplayerId].isShiny))) + case 0: + if (SendBlock(0, &gUnknown_02022C98->unk_318C[gUnknown_02022C98->multiplayerId].isShiny, sizeof(gUnknown_02022C98->unk_318C[gUnknown_02022C98->multiplayerId].isShiny))) + { + gUnknown_02022C98->unk_0008 = 0; + data[0]++; + } + break; + case 1: + if (IsLinkTaskFinished()) + { + data[0]++; + } + break; + case 2: + if (sub_8025170()) + { + for (i = 0; i < gUnknown_02022C98->unk_0024; i++) { - gUnknown_02022C98->unk_0008 = 0; - data[0]++; + *(u8 *)&gUnknown_02022C98->unk_318C[i] = *(u8 *)gBlockRecvBuffer[i]; + gUnknown_02022C98->unk_0008 = gUnknown_02022C98->unk_0024; } - break; - case 1: - if (IsLinkTaskFinished()) - { - data[0]++; - } - break; - case 2: - if (sub_8025170()) - { - for (i = 0; i < gUnknown_02022C98->unk_0024; i++) - { - *(u8 *)&gUnknown_02022C98->unk_318C[i] = *(u8 *)gBlockRecvBuffer[i]; - gUnknown_02022C98->unk_0008 = gUnknown_02022C98->unk_0024; - } - } - if (gUnknown_02022C98->unk_0008 >= gUnknown_02022C98->unk_0024) - { - DestroyTask(taskId); - sub_80292E0(6); - gUnknown_02022C98->unk_0010++; - } - break; + } + if (gUnknown_02022C98->unk_0008 >= gUnknown_02022C98->unk_0024) + { + DestroyTask(taskId); + sub_80292E0(6); + gUnknown_02022C98->unk_0010++; + } + break; } } @@ -1089,29 +1092,29 @@ void sub_80259FC(void) } switch (gUnknown_02022C98->unk_00A8[i]) { - case 0: - default: - break; - case 1 ... 3: - if (++gUnknown_02022C98->unk_00B0[i] >= 6) - { - gUnknown_02022C98->unk_00B0[i] = 0; - gUnknown_02022C98->unk_00A8[i] = 0; - gUnknown_02022C98->unk_31A0[i].unk_2C = 0; - gUnknown_02022C98->unk_31A0[i].unk_30 = 0; - gUnknown_02022C98->unk_31A0[i].unk_34 = 0; - } - break; - case 4: - if (++gUnknown_02022C98->unk_00B0[i] >= 40) - { - gUnknown_02022C98->unk_00B0[i] = 0; - gUnknown_02022C98->unk_00A8[i] = 0; - gUnknown_02022C98->unk_31A0[i].unk_2C = 0; - gUnknown_02022C98->unk_31A0[i].unk_30 = 0; - gUnknown_02022C98->unk_31A0[i].unk_34 = 0; - } - break; + case 0: + default: + break; + case 1 ... 3: + if (++gUnknown_02022C98->unk_00B0[i] >= 6) + { + gUnknown_02022C98->unk_00B0[i] = 0; + gUnknown_02022C98->unk_00A8[i] = 0; + gUnknown_02022C98->unk_31A0[i].unk_2C = 0; + gUnknown_02022C98->unk_31A0[i].unk_30 = 0; + gUnknown_02022C98->unk_31A0[i].unk_34 = 0; + } + break; + case 4: + if (++gUnknown_02022C98->unk_00B0[i] >= 40) + { + gUnknown_02022C98->unk_00B0[i] = 0; + gUnknown_02022C98->unk_00A8[i] = 0; + gUnknown_02022C98->unk_31A0[i].unk_2C = 0; + gUnknown_02022C98->unk_31A0[i].unk_30 = 0; + gUnknown_02022C98->unk_31A0[i].unk_34 = 0; + } + break; } } } @@ -1151,19 +1154,19 @@ void sub_8025D04(void) { switch (gUnknown_02022C98->unk_0018) { - case 3: - if (sub_8026BB8() == 1) - { - sub_8026C28(); - gUnknown_02022C98->unk_011C = 1; - } - break; - case 4: - sub_80259FC(); - break; - case 11: - sub_8025C0C(); - break; + case 3: + if (sub_8026BB8() == 1) + { + sub_8026C28(); + gUnknown_02022C98->unk_011C = 1; + } + break; + case 4: + sub_80259FC(); + break; + case 11: + sub_8025C0C(); + break; } } @@ -1171,12 +1174,12 @@ void sub_8025D50(void) { switch (gUnknown_02022C98->unk_0018) { - case 4: - sub_8027E30(&gUnknown_02022C98->unk_32CC, &gUnknown_02022C98->unk_31A0[0].unk_2C, &gUnknown_02022C98->unk_31A0[1].unk_2C, &gUnknown_02022C98->unk_31A0[2].unk_2C, &gUnknown_02022C98->unk_31A0[3].unk_2C, &gUnknown_02022C98->unk_31A0[4].unk_2C, gUnknown_02022C98->unk_0040, gUnknown_02022C98->unk_0120, gUnknown_02022C98->unk_012C); - break; - case 11: - sub_8027E30(&gUnknown_02022C98->unk_32CC, &gUnknown_02022C98->unk_31A0[0].unk_2C, &gUnknown_02022C98->unk_31A0[1].unk_2C, &gUnknown_02022C98->unk_31A0[2].unk_2C, &gUnknown_02022C98->unk_31A0[3].unk_2C, &gUnknown_02022C98->unk_31A0[4].unk_2C, gUnknown_02022C98->unk_0040, gUnknown_02022C98->unk_0120, gUnknown_02022C98->unk_012C); - break; + case 4: + sub_8027E30(&gUnknown_02022C98->unk_32CC, &gUnknown_02022C98->unk_31A0[0].unk_2C, &gUnknown_02022C98->unk_31A0[1].unk_2C, &gUnknown_02022C98->unk_31A0[2].unk_2C, &gUnknown_02022C98->unk_31A0[3].unk_2C, &gUnknown_02022C98->unk_31A0[4].unk_2C, gUnknown_02022C98->unk_0040, gUnknown_02022C98->unk_0120, gUnknown_02022C98->unk_012C); + break; + case 11: + sub_8027E30(&gUnknown_02022C98->unk_32CC, &gUnknown_02022C98->unk_31A0[0].unk_2C, &gUnknown_02022C98->unk_31A0[1].unk_2C, &gUnknown_02022C98->unk_31A0[2].unk_2C, &gUnknown_02022C98->unk_31A0[3].unk_2C, &gUnknown_02022C98->unk_31A0[4].unk_2C, gUnknown_02022C98->unk_0040, gUnknown_02022C98->unk_0120, gUnknown_02022C98->unk_012C); + break; } } @@ -1184,12 +1187,12 @@ void sub_8025E0C(void) { switch (gUnknown_02022C98->unk_0018) { - case 4: - sub_8028164(gUnknown_02022C98->multiplayerId, &gUnknown_02022C98->unk_31A0[gUnknown_02022C98->multiplayerId], &gUnknown_02022C98->unk_31A0[0].unk_2C, &gUnknown_02022C98->unk_31A0[1].unk_2C, &gUnknown_02022C98->unk_31A0[2].unk_2C, &gUnknown_02022C98->unk_31A0[3].unk_2C, &gUnknown_02022C98->unk_31A0[4].unk_2C, &gUnknown_02022C98->unk_0040, &gUnknown_02022C98->unk_0120, &gUnknown_02022C98->unk_012C); - break; - case 11: - sub_8028164(gUnknown_02022C98->multiplayerId, &gUnknown_02022C98->unk_31A0[gUnknown_02022C98->multiplayerId], &gUnknown_02022C98->unk_31A0[0].unk_2C, &gUnknown_02022C98->unk_31A0[1].unk_2C, &gUnknown_02022C98->unk_31A0[2].unk_2C, &gUnknown_02022C98->unk_31A0[3].unk_2C, &gUnknown_02022C98->unk_31A0[4].unk_2C, &gUnknown_02022C98->unk_0040, &gUnknown_02022C98->unk_0120, &gUnknown_02022C98->unk_012C); - break; + case 4: + sub_8028164(gUnknown_02022C98->multiplayerId, &gUnknown_02022C98->unk_31A0[gUnknown_02022C98->multiplayerId], &gUnknown_02022C98->unk_31A0[0].unk_2C, &gUnknown_02022C98->unk_31A0[1].unk_2C, &gUnknown_02022C98->unk_31A0[2].unk_2C, &gUnknown_02022C98->unk_31A0[3].unk_2C, &gUnknown_02022C98->unk_31A0[4].unk_2C, &gUnknown_02022C98->unk_0040, &gUnknown_02022C98->unk_0120, &gUnknown_02022C98->unk_012C); + break; + case 11: + sub_8028164(gUnknown_02022C98->multiplayerId, &gUnknown_02022C98->unk_31A0[gUnknown_02022C98->multiplayerId], &gUnknown_02022C98->unk_31A0[0].unk_2C, &gUnknown_02022C98->unk_31A0[1].unk_2C, &gUnknown_02022C98->unk_31A0[2].unk_2C, &gUnknown_02022C98->unk_31A0[3].unk_2C, &gUnknown_02022C98->unk_31A0[4].unk_2C, &gUnknown_02022C98->unk_0040, &gUnknown_02022C98->unk_0120, &gUnknown_02022C98->unk_012C); + break; } } @@ -1197,22 +1200,22 @@ void sub_8025ED8(void) { switch (gUnknown_02022C98->unk_0018) { - case 3: - sub_8027DD0(1); - gUnknown_02022C98->unk_011C = 1; - break; - case 4: - if (gUnknown_02022C98->unk_32CC.unk_2C != 0) - { - sub_80282EC(gUnknown_02022C98->unk_32CC.unk_2C); - } - break; - case 11: - if (gUnknown_02022C98->unk_0120 == 0 && gUnknown_02022C98->unk_012C == 0) - { - sub_8028350(1); - } - break; + case 3: + sub_8027DD0(1); + gUnknown_02022C98->unk_011C = 1; + break; + case 4: + if (gUnknown_02022C98->unk_32CC.unk_2C != 0) + { + sub_80282EC(gUnknown_02022C98->unk_32CC.unk_2C); + } + break; + case 11: + if (gUnknown_02022C98->unk_0120 == 0 && gUnknown_02022C98->unk_012C == 0) + { + sub_8028350(1); + } + break; } } @@ -1314,3 +1317,82 @@ void sub_8026044(void) gUnknown_02022C98->unk_0154 = 2; } } + +void sub_80261CC(void) +{ + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); +} + +void sub_80261E4(void) +{ + TransferPlttBuffer(); + LoadOam(); + ProcessSpriteCopyRequests(); +} + +void sub_80261F8(struct DodrioBerryPickingSubstruct_318C * a0, struct Pokemon * a1) +{ + a0->isShiny = IsMonShiny(a1); +} + +void sub_802620C(TaskFunc func, u8 priority) +{ + CreateTask(func, priority); +} + +void sub_802621C(TaskFunc func) +{ + gUnknown_02022C98->unk_0004 = CreateTask(func, 1); + gUnknown_02022C98->unk_0010 = 0; + gUnknown_02022C98->unk_000C = 0; + gUnknown_02022C98->unk_0014 = 0; +} + +void sub_8026240(u8 a0) +{ + gUnknown_02022C98->unk_001C = gUnknown_02022C98->unk_0018; + gUnknown_02022C98->unk_0018 = a0; + gUnknown_02022C98->unk_0010 = 0; + gUnknown_02022C98->unk_0014 = 0; +} + +bool32 sub_8026264(void) +{ + u8 r2 = gUnknown_02022C98->unk_0014 / 4; + gUnknown_02022C98->unk_0014++; + if (r2 != 0 && gUnknown_02022C98->unk_0014 % 4 == 0) + { + if (r2 < gUnknown_082F7A94[gUnknown_02022C98->unk_0024 - 1]) + { + SetGpuReg(REG_OFFSET_BG1HOFS, (r2 * 8)); + SetGpuReg(REG_OFFSET_BG2HOFS, -(r2 * 8)); + return FALSE; + } + else + { + return TRUE; + } + } + else + { + return FALSE; + } +} + +void sub_80262C0(void) +{ + u8 i; + u8 start = gUnknown_02022C98->unk_0044; + u8 finish = gUnknown_02022C98->unk_0048; + + for (i = start; i < finish; i++) + { + struct DodrioBerryPickingSubstruct_31A0 * ptr = &gUnknown_02022C98->unk_32CC; + u8 * r4 = gUnknown_02022C98->unk_32CC.unk_14; + ptr->unk_1F[i] = (i % 2 == 0) ? 1 : 0; + r4[i] = 0; + } +} From df538ff7ab6f0a91e22408fac91254d15d5a24fe Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 26 Mar 2019 08:43:49 -0400 Subject: [PATCH 11/13] WIP sub_8026324 --- .gitignore | 1 + asm/dodrio_berry_picking.s | 387 --------------------------- src/dodrio_berry_picking.c | 532 ++++++++++++++++++++++++++++++++++++- 3 files changed, 526 insertions(+), 394 deletions(-) diff --git a/.gitignore b/.gitignore index dc782899d..1b72e0c77 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ Thumbs.db build/ .DS_Store *.ddump +.idea/ diff --git a/asm/dodrio_berry_picking.s b/asm/dodrio_berry_picking.s index 296f8b006..e833b1640 100755 --- a/asm/dodrio_berry_picking.s +++ b/asm/dodrio_berry_picking.s @@ -5,393 +5,6 @@ .text - thumb_func_start sub_8026324 -sub_8026324: @ 8026324 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x10 - ldr r0, =gUnknown_02022C98 - ldr r1, [r0] - adds r0, r1, 0 - adds r0, 0x44 - ldrb r0, [r0] - str r0, [sp] - adds r0, r1, 0 - adds r0, 0x48 - ldrb r0, [r0] - str r0, [sp, 0x4] - adds r0, r1, 0 - adds r0, 0x24 - ldrb r0, [r0] - str r0, [sp, 0x8] - adds r0, r1, 0 - adds r0, 0x40 - ldrb r0, [r0] - cmp r0, 0x9 - bls _08026358 - b _08026614 -_08026358: - movs r6, 0 - ldr r0, [sp, 0x8] - cmp r6, r0 - bcs _08026440 -_08026360: - ldr r3, =gUnknown_02022C98 - lsls r0, r6, 4 - subs r1, r0, r6 - lsls r1, 2 - ldr r2, [r3] - adds r1, r2 - ldr r4, =0x000031cc - adds r4, r1 - mov r8, r4 - ldrb r1, [r4] - mov r9, r0 - adds r0, r6, 0x1 - str r0, [sp, 0xC] - cmp r1, 0 - beq _08026434 - adds r0, r2, 0 - adds r0, 0xA8 - adds r0, r6 - ldrb r0, [r0] - cmp r0, 0x1 - bne _08026434 - ldr r1, [sp] - mov r10, r1 - ldr r2, [sp, 0x4] - cmp r10, r2 - bcs _08026434 - adds r7, r3, 0 -_08026396: - ldr r0, =gUnknown_082F449C - add r0, r10 - ldrb r5, [r0] - ldr r1, [r7] - lsls r4, r5, 1 - adds r0, r1, 0 - adds r0, 0xF4 - adds r0, r4 - ldrb r0, [r0] - cmp r0, r6 - beq _08026434 - adds r0, r1, 0 - adds r0, 0xF5 - adds r0, r4 - ldrb r0, [r0] - cmp r0, r6 - beq _08026434 - mov r0, r8 - ldrb r1, [r0] - adds r0, r6, 0 - adds r2, r5, 0 - bl sub_8026634 - cmp r0, 0x1 - bne _08026410 - movs r2, 0 - ldr r3, =gUnknown_02022C98 - mov r8, r4 -_080263CE: - ldr r0, [r3] - mov r4, r8 - adds r1, r2, r4 - adds r0, 0xF4 - adds r1, r0, r1 - ldrb r0, [r1] - cmp r0, 0xFF - bne _08026404 - strb r6, [r1] - ldr r0, [r3] - adds r0, 0xA8 - adds r0, r6 - movs r1, 0x2 - strb r1, [r0] - ldr r0, [r3] - adds r0, 0xC4 - adds r0, r5 - movs r1, 0x1 - strb r1, [r0] - b _08026434 - .pool -_08026404: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x1 - bls _080263CE - b _08026434 -_08026410: - ldr r0, [r7] - mov r2, r9 - subs r1, r2, r6 - lsls r1, 2 - adds r0, r1 - ldr r4, =0x000031d4 - adds r0, r4 - ldrb r0, [r0] - cmp r0, 0x1 - beq _08026434 - mov r0, r10 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 - ldr r0, [sp, 0x4] - cmp r10, r0 - bcc _08026396 -_08026434: - ldr r1, [sp, 0xC] - lsls r0, r1, 24 - lsrs r6, r0, 24 - ldr r2, [sp, 0x8] - cmp r6, r2 - bcc _08026360 -_08026440: - ldr r4, [sp] - mov r10, r4 - ldr r0, [sp, 0x4] - cmp r10, r0 - bcc _0802644C - b _08026614 -_0802644C: - ldr r1, =gUnknown_02022C98 - mov r9, r1 -_08026450: - movs r6, 0xFF - ldr r0, =gUnknown_082F449C - add r0, r10 - ldrb r5, [r0] - mov r2, r9 - ldr r0, [r2] - adds r0, 0xC4 - adds r0, r5 - ldrb r0, [r0] - cmp r0, 0x1 - beq _08026468 - b _08026602 -_08026468: - adds r0, r5, 0 - bl sub_8026D8C - mov r1, r9 - ldr r4, [r1] - lsls r0, 24 - lsrs r0, 24 - adds r1, r4, 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 _0802648E - movs r3, 0x2 -_0802648E: - ldr r2, =gUnknown_082F7A88 - ldr r0, =0x000031b4 - adds r1, r4, r0 - adds r1, r5 - lsls r0, r3, 1 - adds r0, r3 - ldrb r1, [r1] - adds r0, r1 - adds r0, r2 - ldrb r1, [r0] - adds r0, r4, 0 - adds r0, 0xD0 - adds r0, r5 - ldrb r0, [r0] - subs r2, r1, r0 - cmp r2, 0x5 - bgt _080264BC - adds r1, r4, 0 - adds r1, 0x9C - adds r1, r5 - ldrb r0, [r1] - adds r0, r2 - strb r0, [r1] -_080264BC: - mov r2, r9 - ldr r1, [r2] - adds r1, 0x9C - adds r1, r5 - ldrb r0, [r1] - adds r0, 0x1 - movs r2, 0 - strb r0, [r1] - movs r4, 0xFF - ands r0, r4 - cmp r0, 0x5 - bhi _080264D6 - b _08026602 -_080264D6: - mov r1, r9 - ldr r0, [r1] - adds r0, 0x9C - adds r0, r5 - strb r2, [r0] - ldr r3, [r1] - lsls r1, r5, 1 - adds r0, r3, 0 - adds r0, 0xF4 - adds r2, r0, r1 - ldrb r0, [r2] - mov r8, r1 - cmp r0, 0xFF - bne _08026518 - adds r0, r3, 0 - adds r0, 0xF5 - add r0, r8 - ldrb r0, [r0] - cmp r0, 0xFF - bne _08026500 - b _08026602 -_08026500: - b _08026528 - .pool -_08026518: - adds r0, r3, 0 - adds r0, 0xF5 - add r0, r8 - ldrb r0, [r0] - cmp r0, 0xFF - bne _08026528 - ldrb r4, [r2] - b _0802654E -_08026528: - mov r2, r9 - ldr r1, [r2] - adds r0, r1, 0 - adds r0, 0xF4 - add r0, r8 - ldrb r7, [r0] - adds r1, 0xF5 - add r1, r8 - ldrb r6, [r1] - bl Random - movs r1, 0x1 - ands r1, r0 - cmp r1, 0 - bne _0802654A - adds r4, r7, 0 - b _0802654E -_0802654A: - adds r4, r6, 0 - adds r6, r7, 0 -_0802654E: - mov r1, r9 - ldr r0, [r1] - ldr r2, =0x000032eb - adds r0, r2 - adds r0, r5 - movs r1, 0x7 - strb r1, [r0] - mov r1, r9 - ldr r0, [r1] - adds r0, 0xC4 - adds r0, r5 - movs r1, 0x2 - strb r1, [r0] - mov r2, r9 - ldr r0, [r2] - adds r0, 0xA8 - adds r0, r4 - movs r1, 0x3 - strb r1, [r0] - ldr r0, [r2] - adds r0, 0xB8 - adds r0, r5 - strb r4, [r0] - ldr r1, [r2] - lsls r0, r4, 4 - subs r0, r4 - lsls r0, 2 - adds r1, r0 - ldr r2, =0x000031d0 - adds r1, r2 - movs r0, 0x1 - strb r0, [r1] - mov r2, r9 - ldr r1, [r2] - lsls r0, r6, 4 - subs r0, r6 - lsls r0, 2 - adds r1, r0 - ldr r0, =0x000031d4 - adds r1, r0 - movs r2, 0x1 - strb r2, [r1] - mov r0, r9 - ldr r1, [r0] - lsls r0, r4, 1 - adds r1, 0x86 - adds r1, r0 - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] - movs r0, 0 - adds r1, r5, 0 - adds r2, r4, 0 - bl sub_8026F1C - movs r0, 0x1 - bl sub_8027234 - adds r0, r4, 0 - bl sub_8026D1C - mov r1, r9 - ldr r0, [r1] - adds r1, r0, 0 - adds r1, 0xE8 - adds r1, r5 - ldr r2, =0x000032e0 - adds r0, r2 - adds r0, r5 - ldrb r0, [r0] - strb r0, [r1] - mov r4, r9 - ldr r0, [r4] - adds r0, r2 - adds r0, r5 - movs r1, 0x3 - strb r1, [r0] - ldr r1, [r4] - adds r1, 0xF4 - add r1, r8 - ldrb r0, [r1] - movs r2, 0xFF - orrs r0, r2 - strb r0, [r1] - ldr r1, [r4] - adds r1, 0xF5 - add r1, r8 - ldrb r0, [r1] - orrs r0, r2 - strb r0, [r1] -_08026602: - mov r0, r10 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 - ldr r4, [sp, 0x4] - cmp r10, r4 - bcs _08026614 - b _08026450 -_08026614: - add sp, 0x10 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8026324 - thumb_func_start sub_8026634 sub_8026634: @ 8026634 push {r4-r7,lr} diff --git a/src/dodrio_berry_picking.c b/src/dodrio_berry_picking.c index 1e698fefb..1531eb4d8 100644 --- a/src/dodrio_berry_picking.c +++ b/src/dodrio_berry_picking.c @@ -4,6 +4,7 @@ #include "window.h" #include "bg.h" #include "gpu_regs.h" +#include "random.h" #include "link.h" #include "link_rfu.h" #include "task.h" @@ -85,19 +86,25 @@ struct DodrioBerryPickingStruct /*0x0048*/ u8 unk_0048; // align 1 /*0x004A*/ u16 unk_004A[5][6]; - /*0x0086*/ u8 filler_0086[18]; + /*0x0086*/ u16 unk_0086[5]; + /*0x0090*/ u8 unk_0090[5]; + /*0x0095*/ u8 filler_0095[3]; /*0x0098*/ u8 unk_0098[4]; - /*0x009C*/ u8 filler_009C[12]; + /*0x009C*/ u8 unk_009C[12]; /*0x00A8*/ u8 unk_00A8[5]; /*0x00AD*/ u8 filler_00AD[3]; /*0x00B0*/ u8 unk_00B0[5]; - /*0x00B5*/ u8 filler_00B5[0xC4 - 0xB5]; + /*0x00B5*/ u8 filler_00B5[3]; + /*0x00B8*/ u8 unk_00B8[5]; + /*0x00BD*/ u8 filler_00BD[7]; /*0x00C4*/ u8 unk_00C4[11]; /*0x00CF*/ u8 filler_00CF[1]; /*0x00D0*/ u8 unk_00D0[11]; /*0x00DB*/ u8 filler_00DB[1]; /*0x00DC*/ u8 unk_00DC[11]; - /*0x00E7*/ u8 filler_0xE7[0xF4 - 0xE7]; + /*0x00E7*/ u8 filler_0xE7[1]; + /*0x00E8*/ u8 unk_00E8[5]; + /*0x00ED*/ u8 filler_00ED[7]; /*0x00F4*/ u8 unk_00F4[11][2]; /*0x010A*/ u8 filler_010A[2]; /*0x010C*/ u8 unk_010C[5]; @@ -170,6 +177,7 @@ void sub_802621C(TaskFunc); void sub_8026240(u8); bool32 sub_8026264(void); void sub_80262C0(void); +u32 sub_8026634(u8, u8, u8); void sub_802671C(void); void sub_8026AF4(void); void sub_8026B28(void); @@ -178,8 +186,12 @@ u32 sub_8026BB8(void); void sub_8026C28(void); bool32 sub_8026C50(void); bool32 sub_8026C90(void); -void sub_80272E8(void); +void sub_8026D1C(u8); +u8 sub_8026D8C(u8); +void sub_8026F1C(u8, u8, u8); +void sub_8027234(u8); void sub_80272A4(void); +void sub_80272E8(void); void sub_80273F0(void); void sub_802749C(void); u8 sub_8027518(u8); @@ -219,11 +231,12 @@ void sub_80292E0(u8); bool32 sub_802A770(void); u8 sub_802A794(void); +extern const u8 gUnknown_082F7A88[][3]; +extern const u8 gUnknown_082F449C[]; +extern const u8 gUnknown_082F7A94[]; extern void (*const gUnknown_082F7AC4[])(void); extern void (*const gUnknown_082F7AF4[])(void); -extern const u8 gUnknown_082F7A94[]; - void sub_802493C(u16 a0, void (*a1)(void)) { gUnknown_03000DB0 = FALSE; @@ -1396,3 +1409,508 @@ void sub_80262C0(void) r4[i] = 0; } } + +#ifdef NONMATCHING +void sub_8026324(void) +{ + u8 sp0 = gUnknown_02022C98->unk_0044; + u8 sp4 = gUnknown_02022C98->unk_0048; + u8 sp8 = gUnknown_02022C98->unk_0024; + u8 r6; + u8 r10; + u8 r2; + u8 r5; + u8 r3; + s32 r2_2; + u8 r4; + u8 r7, r7_2; + + if (gUnknown_02022C98->unk_0040 < 10) + { + for (r6 = 0; r6 < sp8; r6++) + { + if ( gUnknown_02022C98->unk_31A0[r6].unk_2C != 0 + && gUnknown_02022C98->unk_00A8[r6] == 1) + { + for (r10 = sp0; r10 < sp4; r10++) + { + r5 = gUnknown_082F449C[r10]; + if (gUnknown_02022C98->unk_00F4[r5][0] == r6) + { + break; + } + if (gUnknown_02022C98->unk_00F4[r5][1] == r6) + { + break; + } + if (sub_8026634(gUnknown_02022C98->unk_31A0[r6].unk_2C, r6, gUnknown_082F449C[r10]) == 1) + { + for (r2 = 0; r2 < 2; r2++) + { + if (gUnknown_02022C98->unk_00F4[r5][r2] == 0xFF) + { + gUnknown_02022C98->unk_00F4[r5][r2] = r6; + gUnknown_02022C98->unk_00A8[r6] = 2; + gUnknown_02022C98->unk_00C4[r5] = 1; + break; + } + } + break; + } + if (gUnknown_02022C98->unk_31A0[r6].unk_34 == 1) + { + break; + } + } + } + } + for (r10 = sp0; r10 < sp4; r10++) + { + r6 = 0xFF; + r5 = gUnknown_082F449C[r10]; + if (gUnknown_02022C98->unk_00C4[r5] == 1) + { + r3 = gUnknown_02022C98->unk_0090[sub_8026D8C(r5)] / 7; + if (r3 < 2) + { + r3 = 2; + } + r2 = gUnknown_082F7A88[r3][gUnknown_02022C98->unk_31A0[0].unk_14[r5]] - gUnknown_02022C98->unk_00D0[r5]; + if (r2 < 6) + { + gUnknown_02022C98->unk_009C[r5] += r2; + } + if (++gUnknown_02022C98->unk_009C[r5] < 6) + { + gUnknown_02022C98->unk_009C[r5] = 0; + if (gUnknown_02022C98->unk_00F4[r5][0] != 0xFF && gUnknown_02022C98->unk_00F4[r5][1] == 0xFF) + { + r4 = gUnknown_02022C98->unk_00F4[r5][0]; + } + else if (gUnknown_02022C98->unk_00F4[r5][0] == 0xFF && gUnknown_02022C98->unk_00F4[r5][1] == 0xFF) + { + continue; + } + else + { + r7 = gUnknown_02022C98->unk_00F4[r5][0]; + r7_2 = gUnknown_02022C98->unk_00F4[r5][1]; + if ((Random() & 1)) + { + r4 = r7_2; + r6 = r7; + } + else + { + r4 = r7; + r6 = r7_2; + } + } + gUnknown_02022C98->unk_32CC.unk_1F[r5] = 7; + gUnknown_02022C98->unk_00C4[r5] = 2; + gUnknown_02022C98->unk_00A8[r4] = 3; + gUnknown_02022C98->unk_00B8[r5] = r4; + gUnknown_02022C98->unk_31A0[r4].unk_30 = 1; + gUnknown_02022C98->unk_31A0[r6].unk_34 = 1; + gUnknown_02022C98->unk_0086[r4]++; + sub_8026F1C(0, r5, r4); + sub_8027234(1); + sub_8026D1C(r4); + gUnknown_02022C98->unk_00E8[r5] = gUnknown_02022C98->unk_32CC.unk_14[r5]; + gUnknown_02022C98->unk_32CC.unk_14[r5] = 3; + gUnknown_02022C98->unk_00F4[r5][0] = 0xFF; + gUnknown_02022C98->unk_00F4[r5][1] = 0xFF; + } + } + } + } +} +#else +NAKED +void sub_8026324(void) +{ + asm_unified("\tpush {r4-r7,lr}\n" + "\tmov r7, r10\n" + "\tmov r6, r9\n" + "\tmov r5, r8\n" + "\tpush {r5-r7}\n" + "\tsub sp, 0x10\n" + "\tldr r0, =gUnknown_02022C98\n" + "\tldr r1, [r0]\n" + "\tadds r0, r1, 0\n" + "\tadds r0, 0x44\n" + "\tldrb r0, [r0]\n" + "\tstr r0, [sp]\n" + "\tadds r0, r1, 0\n" + "\tadds r0, 0x48\n" + "\tldrb r0, [r0]\n" + "\tstr r0, [sp, 0x4]\n" + "\tadds r0, r1, 0\n" + "\tadds r0, 0x24\n" + "\tldrb r0, [r0]\n" + "\tstr r0, [sp, 0x8]\n" + "\tadds r0, r1, 0\n" + "\tadds r0, 0x40\n" + "\tldrb r0, [r0]\n" + "\tcmp r0, 0x9\n" + "\tbls _08026358\n" + "\tb _08026614\n" + "_08026358:\n" + "\tmovs r6, 0\n" + "\tldr r0, [sp, 0x8]\n" + "\tcmp r6, r0\n" + "\tbcs _08026440\n" + "_08026360:\n" + "\tldr r3, =gUnknown_02022C98\n" + "\tlsls r0, r6, 4\n" + "\tsubs r1, r0, r6\n" + "\tlsls r1, 2\n" + "\tldr r2, [r3]\n" + "\tadds r1, r2\n" + "\tldr r4, =0x000031cc\n" + "\tadds r4, r1\n" + "\tmov r8, r4\n" + "\tldrb r1, [r4]\n" + "\tmov r9, r0\n" + "\tadds r0, r6, 0x1\n" + "\tstr r0, [sp, 0xC]\n" + "\tcmp r1, 0\n" + "\tbeq _08026434\n" + "\tadds r0, r2, 0\n" + "\tadds r0, 0xA8\n" + "\tadds r0, r6\n" + "\tldrb r0, [r0]\n" + "\tcmp r0, 0x1\n" + "\tbne _08026434\n" + "\tldr r1, [sp]\n" + "\tmov r10, r1\n" + "\tldr r2, [sp, 0x4]\n" + "\tcmp r10, r2\n" + "\tbcs _08026434\n" + "\tadds r7, r3, 0\n" + "_08026396:\n" + "\tldr r0, =gUnknown_082F449C\n" + "\tadd r0, r10\n" + "\tldrb r5, [r0]\n" + "\tldr r1, [r7]\n" + "\tlsls r4, r5, 1\n" + "\tadds r0, r1, 0\n" + "\tadds r0, 0xF4\n" + "\tadds r0, r4\n" + "\tldrb r0, [r0]\n" + "\tcmp r0, r6\n" + "\tbeq _08026434\n" + "\tadds r0, r1, 0\n" + "\tadds r0, 0xF5\n" + "\tadds r0, r4\n" + "\tldrb r0, [r0]\n" + "\tcmp r0, r6\n" + "\tbeq _08026434\n" + "\tmov r0, r8\n" + "\tldrb r1, [r0]\n" + "\tadds r0, r6, 0\n" + "\tadds r2, r5, 0\n" + "\tbl sub_8026634\n" + "\tcmp r0, 0x1\n" + "\tbne _08026410\n" + "\tmovs r2, 0\n" + "\tldr r3, =gUnknown_02022C98\n" + "\tmov r8, r4\n" + "_080263CE:\n" + "\tldr r0, [r3]\n" + "\tmov r4, r8\n" + "\tadds r1, r2, r4\n" + "\tadds r0, 0xF4\n" + "\tadds r1, r0, r1\n" + "\tldrb r0, [r1]\n" + "\tcmp r0, 0xFF\n" + "\tbne _08026404\n" + "\tstrb r6, [r1]\n" + "\tldr r0, [r3]\n" + "\tadds r0, 0xA8\n" + "\tadds r0, r6\n" + "\tmovs r1, 0x2\n" + "\tstrb r1, [r0]\n" + "\tldr r0, [r3]\n" + "\tadds r0, 0xC4\n" + "\tadds r0, r5\n" + "\tmovs r1, 0x1\n" + "\tstrb r1, [r0]\n" + "\tb _08026434\n" + "\t.pool\n" + "_08026404:\n" + "\tadds r0, r2, 0x1\n" + "\tlsls r0, 24\n" + "\tlsrs r2, r0, 24\n" + "\tcmp r2, 0x1\n" + "\tbls _080263CE\n" + "\tb _08026434\n" + "_08026410:\n" + "\tldr r0, [r7]\n" + "\tmov r2, r9\n" + "\tsubs r1, r2, r6\n" + "\tlsls r1, 2\n" + "\tadds r0, r1\n" + "\tldr r4, =0x000031d4\n" + "\tadds r0, r4\n" + "\tldrb r0, [r0]\n" + "\tcmp r0, 0x1\n" + "\tbeq _08026434\n" + "\tmov r0, r10\n" + "\tadds r0, 0x1\n" + "\tlsls r0, 24\n" + "\tlsrs r0, 24\n" + "\tmov r10, r0\n" + "\tldr r0, [sp, 0x4]\n" + "\tcmp r10, r0\n" + "\tbcc _08026396\n" + "_08026434:\n" + "\tldr r1, [sp, 0xC]\n" + "\tlsls r0, r1, 24\n" + "\tlsrs r6, r0, 24\n" + "\tldr r2, [sp, 0x8]\n" + "\tcmp r6, r2\n" + "\tbcc _08026360\n" + "_08026440:\n" + "\tldr r4, [sp]\n" + "\tmov r10, r4\n" + "\tldr r0, [sp, 0x4]\n" + "\tcmp r10, r0\n" + "\tbcc _0802644C\n" + "\tb _08026614\n" + "_0802644C:\n" + "\tldr r1, =gUnknown_02022C98\n" + "\tmov r9, r1\n" + "_08026450:\n" + "\tmovs r6, 0xFF\n" + "\tldr r0, =gUnknown_082F449C\n" + "\tadd r0, r10\n" + "\tldrb r5, [r0]\n" + "\tmov r2, r9\n" + "\tldr r0, [r2]\n" + "\tadds r0, 0xC4\n" + "\tadds r0, r5\n" + "\tldrb r0, [r0]\n" + "\tcmp r0, 0x1\n" + "\tbeq _08026468\n" + "\tb _08026602\n" + "_08026468:\n" + "\tadds r0, r5, 0\n" + "\tbl sub_8026D8C\n" + "\tmov r1, r9\n" + "\tldr r4, [r1]\n" + "\tlsls r0, 24\n" + "\tlsrs r0, 24\n" + "\tadds r1, r4, 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 _0802648E\n" + "\tmovs r3, 0x2\n" + "_0802648E:\n" + "\tldr r2, =gUnknown_082F7A88\n" + "\tldr r0, =0x000031b4\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 r1, [r0]\n" + "\tadds r0, r4, 0\n" + "\tadds r0, 0xD0\n" + "\tadds r0, r5\n" + "\tldrb r0, [r0]\n" + "\tsubs r2, r1, r0\n" + "\tcmp r2, 0x5\n" + "\tbgt _080264BC\n" + "\tadds r1, r4, 0\n" + "\tadds r1, 0x9C\n" + "\tadds r1, r5\n" + "\tldrb r0, [r1]\n" + "\tadds r0, r2\n" + "\tstrb r0, [r1]\n" + "_080264BC:\n" + "\tmov r2, r9\n" + "\tldr r1, [r2]\n" + "\tadds r1, 0x9C\n" + "\tadds r1, r5\n" + "\tldrb r0, [r1]\n" + "\tadds r0, 0x1\n" + "\tmovs r2, 0\n" + "\tstrb r0, [r1]\n" + "\tmovs r4, 0xFF\n" + "\tands r0, r4\n" + "\tcmp r0, 0x5\n" + "\tbhi _080264D6\n" + "\tb _08026602\n" + "_080264D6:\n" + "\tmov r1, r9\n" + "\tldr r0, [r1]\n" + "\tadds r0, 0x9C\n" + "\tadds r0, r5\n" + "\tstrb r2, [r0]\n" + "\tldr r3, [r1]\n" + "\tlsls r1, r5, 1\n" + "\tadds r0, r3, 0\n" + "\tadds r0, 0xF4\n" + "\tadds r2, r0, r1\n" + "\tldrb r0, [r2]\n" + "\tmov r8, r1\n" + "\tcmp r0, 0xFF\n" + "\tbne _08026518\n" + "\tadds r0, r3, 0\n" + "\tadds r0, 0xF5\n" + "\tadd r0, r8\n" + "\tldrb r0, [r0]\n" + "\tcmp r0, 0xFF\n" + "\tbne _08026500\n" + "\tb _08026602\n" + "_08026500:\n" + "\tb _08026528\n" + "\t.pool\n" + "_08026518:\n" + "\tadds r0, r3, 0\n" + "\tadds r0, 0xF5\n" + "\tadd r0, r8\n" + "\tldrb r0, [r0]\n" + "\tcmp r0, 0xFF\n" + "\tbne _08026528\n" + "\tldrb r4, [r2]\n" + "\tb _0802654E\n" + "_08026528:\n" + "\tmov r2, r9\n" + "\tldr r1, [r2]\n" + "\tadds r0, r1, 0\n" + "\tadds r0, 0xF4\n" + "\tadd r0, r8\n" + "\tldrb r7, [r0]\n" + "\tadds r1, 0xF5\n" + "\tadd r1, r8\n" + "\tldrb r6, [r1]\n" + "\tbl Random\n" + "\tmovs r1, 0x1\n" + "\tands r1, r0\n" + "\tcmp r1, 0\n" + "\tbne _0802654A\n" + "\tadds r4, r7, 0\n" + "\tb _0802654E\n" + "_0802654A:\n" + "\tadds r4, r6, 0\n" + "\tadds r6, r7, 0\n" + "_0802654E:\n" + "\tmov r1, r9\n" + "\tldr r0, [r1]\n" + "\tldr r2, =0x000032eb\n" + "\tadds r0, r2\n" + "\tadds r0, r5\n" + "\tmovs r1, 0x7\n" + "\tstrb r1, [r0]\n" + "\tmov r1, r9\n" + "\tldr r0, [r1]\n" + "\tadds r0, 0xC4\n" + "\tadds r0, r5\n" + "\tmovs r1, 0x2\n" + "\tstrb r1, [r0]\n" + "\tmov r2, r9\n" + "\tldr r0, [r2]\n" + "\tadds r0, 0xA8\n" + "\tadds r0, r4\n" + "\tmovs r1, 0x3\n" + "\tstrb r1, [r0]\n" + "\tldr r0, [r2]\n" + "\tadds r0, 0xB8\n" + "\tadds r0, r5\n" + "\tstrb r4, [r0]\n" + "\tldr r1, [r2]\n" + "\tlsls r0, r4, 4\n" + "\tsubs r0, r4\n" + "\tlsls r0, 2\n" + "\tadds r1, r0\n" + "\tldr r2, =0x000031d0\n" + "\tadds r1, r2\n" + "\tmovs r0, 0x1\n" + "\tstrb r0, [r1]\n" + "\tmov r2, r9\n" + "\tldr r1, [r2]\n" + "\tlsls r0, r6, 4\n" + "\tsubs r0, r6\n" + "\tlsls r0, 2\n" + "\tadds r1, r0\n" + "\tldr r0, =0x000031d4\n" + "\tadds r1, r0\n" + "\tmovs r2, 0x1\n" + "\tstrb r2, [r1]\n" + "\tmov r0, r9\n" + "\tldr r1, [r0]\n" + "\tlsls r0, r4, 1\n" + "\tadds r1, 0x86\n" + "\tadds r1, r0\n" + "\tldrh r0, [r1]\n" + "\tadds r0, 0x1\n" + "\tstrh r0, [r1]\n" + "\tmovs r0, 0\n" + "\tadds r1, r5, 0\n" + "\tadds r2, r4, 0\n" + "\tbl sub_8026F1C\n" + "\tmovs r0, 0x1\n" + "\tbl sub_8027234\n" + "\tadds r0, r4, 0\n" + "\tbl sub_8026D1C\n" + "\tmov r1, r9\n" + "\tldr r0, [r1]\n" + "\tadds r1, r0, 0\n" + "\tadds r1, 0xE8\n" + "\tadds r1, r5\n" + "\tldr r2, =0x000032e0\n" + "\tadds r0, r2\n" + "\tadds r0, r5\n" + "\tldrb r0, [r0]\n" + "\tstrb r0, [r1]\n" + "\tmov r4, r9\n" + "\tldr r0, [r4]\n" + "\tadds r0, r2\n" + "\tadds r0, r5\n" + "\tmovs r1, 0x3\n" + "\tstrb r1, [r0]\n" + "\tldr r1, [r4]\n" + "\tadds r1, 0xF4\n" + "\tadd r1, r8\n" + "\tldrb r0, [r1]\n" + "\tmovs r2, 0xFF\n" + "\torrs r0, r2\n" + "\tstrb r0, [r1]\n" + "\tldr r1, [r4]\n" + "\tadds r1, 0xF5\n" + "\tadd r1, r8\n" + "\tldrb r0, [r1]\n" + "\torrs r0, r2\n" + "\tstrb r0, [r1]\n" + "_08026602:\n" + "\tmov r0, r10\n" + "\tadds r0, 0x1\n" + "\tlsls r0, 24\n" + "\tlsrs r0, 24\n" + "\tmov r10, r0\n" + "\tldr r4, [sp, 0x4]\n" + "\tcmp r10, r4\n" + "\tbcs _08026614\n" + "\tb _08026450\n" + "_08026614:\n" + "\tadd sp, 0x10\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 From 2eba82b0fb0c716f03c2244abcd2a005d6af19e7 Mon Sep 17 00:00:00 2001 From: scnorton Date: Tue, 26 Mar 2019 11:59:39 -0400 Subject: [PATCH 12/13] sub_8026634 --- asm/dodrio_berry_picking.s | 116 ------------------------------------ data/dodrio_berry_picking.s | 59 +++++++++--------- src/dodrio_berry_picking.c | 76 ++++++++++++++++++----- 3 files changed, 93 insertions(+), 158 deletions(-) diff --git a/asm/dodrio_berry_picking.s b/asm/dodrio_berry_picking.s index e833b1640..b802c2653 100755 --- a/asm/dodrio_berry_picking.s +++ b/asm/dodrio_berry_picking.s @@ -5,122 +5,6 @@ .text - thumb_func_start sub_8026634 -sub_8026634: @ 8026634 - push {r4-r7,lr} - lsls r0, 24 - lsrs r4, r0, 24 - lsls r1, 24 - lsrs r3, r1, 24 - lsls r2, 24 - lsrs r6, r2, 24 - movs r7, 0 - ldr r2, =gUnknown_02022C98 - ldr r1, [r2] - adds r0, r1, 0 - adds r0, 0x24 - ldrb r0, [r0] - subs r0, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, =0x000032e0 - adds r1, r0 - mov r12, r2 - cmp r3, 0x2 - beq _08026670 - cmp r3, 0x2 - bgt _08026676 - cmp r3, 0x1 - beq _08026674 - b _08026676 - .pool -_08026670: - movs r7, 0x1 - b _08026676 -_08026674: - movs r7, 0x2 -_08026676: - adds r0, r1, 0 - adds r0, 0xB - adds r0, r6 - ldrb r0, [r0] - subs r0, 0x6 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bhi _080266D4 - ldr r0, =gUnknown_082F449C+0x113 - lsls r1, r4, 1 - adds r1, r4 - adds r1, r7, r1 - lsls r2, r5, 4 - subs r2, r5 - adds r1, r2 - adds r1, r0 - ldrb r1, [r1] - cmp r6, r1 - bne _0802670A - mov r0, r12 - ldr r1, [r0] - adds r0, r1, 0 - adds r0, 0xC4 - adds r0, r6 - ldrb r0, [r0] - subs r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bhi _080266D0 - lsls r0, r4, 4 - subs r0, r4 - lsls r0, 2 - adds r0, r1, r0 - ldr r1, =0x000031d4 - adds r0, r1 - movs r1, 0x1 - strb r1, [r0] - b _0802670A - .pool -_080266D0: - movs r0, 0x1 - b _0802670C -_080266D4: - ldr r0, =gUnknown_082F449C+0x113 - lsls r1, r4, 1 - adds r1, r4 - adds r1, r7, r1 - lsls r2, r5, 4 - subs r2, r5 - adds r1, r2 - adds r1, r0 - ldrb r1, [r1] - cmp r6, r1 - bne _0802670A - mov r1, r12 - ldr r0, [r1] - adds r0, 0xA8 - adds r0, r4 - movs r1, 0x4 - strb r1, [r0] - mov r0, r12 - ldr r1, [r0] - lsls r0, r4, 4 - subs r0, r4 - lsls r0, 2 - adds r1, r0 - ldr r0, =0x000031d4 - adds r1, r0 - movs r0, 0x1 - strb r0, [r1] -_0802670A: - movs r0, 0 -_0802670C: - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8026634 - thumb_func_start sub_802671C sub_802671C: @ 802671C push {r4-r7,lr} diff --git a/data/dodrio_berry_picking.s b/data/dodrio_berry_picking.s index 38701c199..7537d9f04 100755 --- a/data/dodrio_berry_picking.s +++ b/data/dodrio_berry_picking.s @@ -39,36 +39,39 @@ gUnknown_082F449C:: @ 82F449C .byte 0x00, 0x01, 0x02, 0x03, 0x04, 0x06, 0x07, 0x08 .byte 0x09, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 .byte 0x08, 0x09, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 - .byte 0x06, 0x07, 0x08, 0x04, 0x05, 0x06, 0x00, 0x00 + .byte 0x06, 0x07, 0x08 + +gUknnown_082F45AF:: + .byte 0x04, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03 + .byte 0x04, 0x05, 0x05, 0x06, 0x03, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x05 + .byte 0x06, 0x06, 0x07, 0x02, 0x02, 0x03, 0x04, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x05 + .byte 0x05, 0x06, 0x07, 0x07, 0x08, 0x01, 0x01, 0x02 + .byte 0x03, 0x00, 0x00, 0x00, 0x04, 0x05, 0x06, 0x06 + .byte 0x07, 0x08, 0x08, 0x09, 0x00, 0x00, 0x01, 0x02 + .byte 0x02, 0x03, 0x04, 0x01, 0x00, 0x01, 0x00, 0x00 .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x03, 0x04, 0x05, 0x05, 0x06, 0x03 + .byte 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00 .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x04, 0x05, 0x06, 0x06, 0x07, 0x02, 0x02 - .byte 0x03, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x03, 0x04, 0x05, 0x05, 0x06, 0x07, 0x07, 0x08 - .byte 0x01, 0x01, 0x02, 0x03, 0x00, 0x00, 0x00, 0x04 - .byte 0x05, 0x06, 0x06, 0x07, 0x08, 0x08, 0x09, 0x00 - .byte 0x00, 0x01, 0x02, 0x02, 0x03, 0x04, 0x01, 0x00 - .byte 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01 - .byte 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00 - .byte 0x01, 0x02, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x01 - .byte 0x02, 0x01, 0x02, 0x03, 0x02, 0x03, 0x00, 0x00 - .byte 0x00, 0x00, 0x04, 0x00, 0x01, 0x00, 0x01, 0x02 - .byte 0x01, 0x02, 0x03, 0x02, 0x03, 0x04, 0x03, 0x04 - .byte 0x00, 0x00, 0x00, 0x00, 0x09, 0x09, 0x09, 0x09 - .byte 0x01, 0x01, 0x01, 0x09, 0x09, 0x09, 0x09, 0x09 - .byte 0x09, 0x09, 0x00, 0x00, 0x01, 0x01, 0x00, 0x09 - .byte 0x09, 0x09, 0x09, 0x09, 0x02, 0x02, 0x00, 0x00 - .byte 0x01, 0x01, 0x01, 0x09, 0x09, 0x09, 0x03, 0x03 - .byte 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x09 - .byte 0x03, 0x03, 0x04, 0x04, 0x00, 0x00, 0x01, 0x01 - .byte 0x02, 0x02, 0x03, 0x05, 0x00, 0x00, 0x00, 0x00 - .byte 0x04, 0x06, 0x00, 0x00, 0x00, 0x03, 0x05, 0x07 - .byte 0x00, 0x00, 0x02, 0x04, 0x06, 0x08, 0x00, 0x01 - .byte 0x03, 0x05, 0x06, 0x09 + .byte 0x00, 0x02, 0x00, 0x01, 0x00, 0x01, 0x02, 0x01 + .byte 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x03, 0x00, 0x01, 0x00, 0x01, 0x02, 0x01, 0x02 + .byte 0x03, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x04 + .byte 0x00, 0x01, 0x00, 0x01, 0x02, 0x01, 0x02, 0x03 + .byte 0x02, 0x03, 0x04, 0x03, 0x04, 0x00, 0x00, 0x00 + .byte 0x00, 0x09, 0x09, 0x09, 0x09, 0x01, 0x01, 0x01 + .byte 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x00 + .byte 0x00, 0x01, 0x01, 0x00, 0x09, 0x09, 0x09, 0x09 + .byte 0x09, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01 + .byte 0x09, 0x09, 0x09, 0x03, 0x03, 0x00, 0x00, 0x01 + .byte 0x01, 0x02, 0x02, 0x03, 0x09, 0x03, 0x03, 0x04 + .byte 0x04, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x03 + .byte 0x05, 0x00, 0x00, 0x00, 0x00, 0x04, 0x06, 0x00 + .byte 0x00, 0x00, 0x03, 0x05, 0x07, 0x00, 0x00, 0x02 + .byte 0x04, 0x06, 0x08, 0x00, 0x01, 0x03, 0x05, 0x06 + .byte 0x09 .align 2 gUnknown_082F7DF0_UnrefDupe:: @ 82F4698 diff --git a/src/dodrio_berry_picking.c b/src/dodrio_berry_picking.c index 1531eb4d8..4d9846c16 100644 --- a/src/dodrio_berry_picking.c +++ b/src/dodrio_berry_picking.c @@ -30,13 +30,17 @@ struct DodrioBerryPickingStruct_2022CF4 u8 filler_00[0x40]; }; // size = 0x40 +struct DodrioBerryPickingSubstruct_31A0_14 +{ + u8 unk_0[11]; + u8 unk_B[11]; +}; + struct DodrioBerryPickingSubstruct_31A0 { u8 unk_00[0x10]; u32 unk_10; - u8 unk_14[11]; - u8 unk_1F[11]; - u8 filler_2A[2]; + struct DodrioBerryPickingSubstruct_31A0_14 unk_14; u8 unk_2C; u8 filler_2D[3]; u8 unk_30; @@ -233,6 +237,7 @@ u8 sub_802A794(void); extern const u8 gUnknown_082F7A88[][3]; extern const u8 gUnknown_082F449C[]; +extern const u8 gUknnown_082F45AF[]; extern const u8 gUnknown_082F7A94[]; extern void (*const gUnknown_082F7AC4[])(void); extern void (*const gUnknown_082F7AF4[])(void); @@ -1304,13 +1309,12 @@ void sub_8026044(void) } for (r4 = r8; r4 < r7; r4++) { - struct DodrioBerryPickingSubstruct_31A0 * ptr = &gUnknown_02022C98->unk_31A0[gUnknown_02022C98->multiplayerId]; - u8 * r1 = ptr->unk_14; - if (ptr->unk_1F[r4] >= 10) + struct DodrioBerryPickingSubstruct_31A0_14 * ptr = &gUnknown_02022C98->unk_31A0[gUnknown_02022C98->multiplayerId].unk_14; + if (ptr->unk_B[r4] >= 10) { if (gUnknown_02022C98->unk_0148[r4] == 0) { - PlaySE(SE_FUUSEN1 + r1[r4]); + PlaySE(SE_FUUSEN1 + ptr->unk_0[r4]); gUnknown_02022C98->unk_0148[r4] = 1; } } @@ -1403,10 +1407,9 @@ void sub_80262C0(void) for (i = start; i < finish; i++) { - struct DodrioBerryPickingSubstruct_31A0 * ptr = &gUnknown_02022C98->unk_32CC; - u8 * r4 = gUnknown_02022C98->unk_32CC.unk_14; - ptr->unk_1F[i] = (i % 2 == 0) ? 1 : 0; - r4[i] = 0; + struct DodrioBerryPickingSubstruct_31A0_14 * ptr = &gUnknown_02022C98->unk_32CC.unk_14; + ptr->unk_B[i] = (i % 2 == 0) ? 1 : 0; + ptr->unk_0[i] = 0; } } @@ -1475,7 +1478,7 @@ void sub_8026324(void) { r3 = 2; } - r2 = gUnknown_082F7A88[r3][gUnknown_02022C98->unk_31A0[0].unk_14[r5]] - gUnknown_02022C98->unk_00D0[r5]; + r2 = gUnknown_082F7A88[r3][gUnknown_02022C98->unk_31A0[0].unk_14.unk_0[r5]] - gUnknown_02022C98->unk_00D0[r5]; if (r2 < 6) { gUnknown_02022C98->unk_009C[r5] += r2; @@ -1516,8 +1519,8 @@ void sub_8026324(void) sub_8026F1C(0, r5, r4); sub_8027234(1); sub_8026D1C(r4); - gUnknown_02022C98->unk_00E8[r5] = gUnknown_02022C98->unk_32CC.unk_14[r5]; - gUnknown_02022C98->unk_32CC.unk_14[r5] = 3; + gUnknown_02022C98->unk_00E8[r5] = gUnknown_02022C98->unk_32CC.unk_14.unk_0[r5]; + gUnknown_02022C98->unk_32CC.unk_14.unk_0[r5] = 3; gUnknown_02022C98->unk_00F4[r5][0] = 0xFF; gUnknown_02022C98->unk_00F4[r5][1] = 0xFF; } @@ -1914,3 +1917,48 @@ void sub_8026324(void) "\t.pool"); } #endif // NONMATCHING + +u32 sub_8026634(u8 a0, u8 a1, u8 a2) +{ + s32 r7 = 0; + u8 r5 = gUnknown_02022C98->unk_0024 - 1; + struct DodrioBerryPickingSubstruct_31A0_14 * ptr = &gUnknown_02022C98->unk_32CC.unk_14; + + switch (a1) + { + case 3: + default: + r7 = 0; + break; + case 2: + r7 = 1; + break; + case 1: + r7 = 2; + break; + } + if (ptr->unk_B[a2] == 6 || ptr->unk_B[a2] == 7) + { + if (a2 == gUknnown_082F45AF[r7 + a0 * 3 + 15 * r5]) + { + if (gUnknown_02022C98->unk_00C4[a2] == 1 || gUnknown_02022C98->unk_00C4[a2] == 2) + { + gUnknown_02022C98->unk_31A0[a0].unk_34 = 1; + return FALSE; + } + else + { + return TRUE; + } + } + } + else + { + if (a2 == gUknnown_082F45AF[r7 + a0 * 3 + 15 * r5]) + { + gUnknown_02022C98->unk_00A8[a0] = 4; + gUnknown_02022C98->unk_31A0[a0].unk_34 = 1; + } + } + return FALSE; +} From a677d1f4cb6f2925e9694b8d2b408273dcd13d9b Mon Sep 17 00:00:00 2001 From: scnorton Date: Tue, 26 Mar 2019 14:46:58 -0400 Subject: [PATCH 13/13] 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 b802c2653..f8bfc3897 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 4d9846c16..38157aa92 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