diff --git a/asm/include/overlay_16.inc b/asm/include/overlay_16.inc deleted file mode 100644 index 6c47fb50f5..0000000000 --- a/asm/include/overlay_16.inc +++ /dev/null @@ -1,61 +0,0 @@ -#include -#pragma once -.public UnloadOverlayByID -.public HandleLoadOverlay -.public OverlayManager_New -.public OverlayManager_Delete -.public OverlayManager_CreateAndGetData -.public OverlayManager_GetData -.public OverlayManager_FreeData -.public OverlayManager_GetArgs -.public OverlayManager_Run -.public NARC_New -.public NARC_Delete -.public NARC_AllocAndReadWholeMember -.public CreateHeap -.public DestroyHeap -.public AllocFromHeap -.public FreeToHeap -.public GF_AssertFail -.public sub_0207789C -.public sub_02077904 -.public sub_0207790C -.public Bag_GetQuantity -.public Bag_CreateView -.public Save_Bag_Get -.public BagCursor_New -.public MI_CpuFill8 -.public _s32_div_f -.public ov15_BagApp_Init -.public ov15_BagApp_Exec -.public ov15_BagApp_Exit -.public ov16_022014A0 -.public ov16_022015B0 -.public ov16_022015BC -.public ov16_022015C4 -.public ov16_022015E0 -.public ov16_022015EC -.public ov16_022015F8 -.public ov16_02201604 -.public ov16_02201610 -.public ov16_02201644 -.public ov16_02201650 -.public ov16_0220165C -.public ov16_02201668 -.public ov16_02201674 -.public ov16_02201760 -.public ov16_022017FC -.public ov16_02201820 -.public ov16_022018B4 -.public ov16_022018C4 -.public ov16_022018D4 -.public ov16_022018E4 -.public ov16_022018F0 -.public ov16_0220191C -.public ov16_0220196C -.public ov16_022019B8 -.public ov16_02201A04 -.public ov17_02201BC0 -.public ov17_02201C10 -.public ov17_02201C78 -.public ov17_02201D04 diff --git a/asm/include/overlay_17.inc b/asm/include/overlay_17.inc index 64354b9b64..65b5a71eb3 100644 --- a/asm/include/overlay_17.inc +++ b/asm/include/overlay_17.inc @@ -143,28 +143,28 @@ .public _s32_div_f .public gSystem .public ov16_022014A0 -.public ov16_022015B0 -.public ov16_022015BC +.public BerryPots_GetPotGrowthStage +.public BerryPots_GetPotBerryId .public ov16_022015C4 -.public ov16_022015E0 +.public BerryPots_GetPotMoisture .public ov16_022015EC .public ov16_022015F8 .public ov16_02201604 .public ov16_02201610 -.public ov16_02201644 -.public ov16_02201650 -.public ov16_0220165C +.public BerryPots_ResetPotMoisture +.public BerryPots_GetPotMulch +.public BerryPots_SetPotMulch .public ov16_02201668 .public ov16_02201674 .public ov16_02201760 .public ov16_022017FC .public ov16_02201820 -.public ov16_022018B4 -.public ov16_022018C4 -.public ov16_022018D4 -.public ov16_022018E4 -.public ov16_022018F0 -.public ov16_0220191C +.public BerryIdToItemId +.public ItemIdToBerryId +.public MulchIdToItemId +.public ItemIdToMulchId +.public GetTotalBerryQuantity +.public GetTotalMulchQuantity .public ov17_02201BC0 .public ov17_02201C10 .public ov17_02201C78 diff --git a/asm/include/unk_0203E348.inc b/asm/include/unk_0203E348.inc index bd0c47b03d..8ce815e163 100644 --- a/asm/include/unk_0203E348.inc +++ b/asm/include/unk_0203E348.inc @@ -93,7 +93,7 @@ .public sub_0203EBA4 .public Fsys_CreateApplication_AlphPuzzle .public CreateUnownReportWork -.public CreateBerryPotsWork +.public BerryPotsArgs_New .public CreateApricornBoxWork .public sub_0203ED80 .public sub_0203EDDC diff --git a/asm/overlay_16.s b/asm/overlay_16.s deleted file mode 100644 index f94a762127..0000000000 --- a/asm/overlay_16.s +++ /dev/null @@ -1,1064 +0,0 @@ - .include "asm/macros.inc" - .include "overlay_16.inc" - .include "global.inc" - - .text - - thumb_func_start ov16_022014A0 -ov16_022014A0: ; 0x022014A0 - push {r3, r4, r5, r6, r7, lr} - sub sp, #8 - add r7, r0, #0 - bl ov16_02201840 - str r0, [sp] - add r0, r7, #0 - mov r1, #0xc0 - bl AllocFromHeap - str r0, [sp, #4] - mov r6, #0 - add r5, r0, #0 -_022014BA: - ldr r0, [sp] - add r1, r6, #0 - add r2, r7, #0 - bl ov16_0220184C - add r4, r0, #0 - mov r1, #3 - bl ov16_0220185C - strb r0, [r5] - add r0, r4, #0 - mov r1, #4 - bl ov16_0220185C - strb r0, [r5, #1] - add r0, r4, #0 - mov r1, #2 - bl ov16_0220185C - strb r0, [r5, #2] - add r0, r4, #0 - bl FreeToHeap - add r6, r6, #1 - add r5, r5, #3 - cmp r6, #0x40 - blt _022014BA - ldr r0, [sp] - bl ov16_02201854 - ldr r0, [sp, #4] - add sp, #8 - pop {r3, r4, r5, r6, r7, pc} - thumb_func_end ov16_022014A0 - - thumb_func_start ov16_022014FC -ov16_022014FC: ; 0x022014FC - mov r1, #0 - strb r1, [r0] - strb r1, [r0, #1] - strh r1, [r0, #2] - strh r1, [r0, #4] - strb r1, [r0, #8] - strh r1, [r0, #6] - strb r1, [r0, #9] - strb r1, [r0, #0xa] - strb r1, [r0, #0xb] - bx lr - .balign 4, 0 - thumb_func_end ov16_022014FC - - thumb_func_start ov16_02201514 -ov16_02201514: ; 0x02201514 - ldrb r2, [r0, #0xa] - ldrb r0, [r0] - sub r3, r0, #1 - lsl r0, r3, #1 - add r0, r3, r0 - add r0, r1, r0 - ldrb r0, [r0, #2] - mul r0, r2 - bx lr - .balign 4, 0 - thumb_func_end ov16_02201514 - - thumb_func_start ov16_02201528 -ov16_02201528: ; 0x02201528 - sub r3, r1, #1 - lsl r1, r3, #1 - add r1, r3, r1 - ldrb r1, [r0, r1] - mov r0, #0x3c - mul r0, r1 - cmp r2, #1 - bne _02201546 - lsl r1, r0, #1 - add r1, r0, r1 - asr r0, r1, #1 - lsr r0, r0, #0x1e - add r0, r1, r0 - asr r0, r0, #2 - bx lr -_02201546: - cmp r2, #2 - bne _02201552 - lsr r1, r0, #0x1f - add r1, r0, r1 - asr r1, r1, #1 - add r0, r0, r1 -_02201552: - bx lr - thumb_func_end ov16_02201528 - - thumb_func_start ov16_02201554 -ov16_02201554: ; 0x02201554 - sub r3, r1, #1 - lsl r1, r3, #1 - add r1, r3, r1 - add r0, r0, r1 - ldrb r0, [r0, #1] - cmp r2, #2 - bne _0220156A - lsr r1, r0, #0x1f - add r1, r0, r1 - asr r0, r1, #1 - bx lr -_0220156A: - cmp r2, #1 - bne _02201576 - lsr r1, r0, #0x1f - add r1, r0, r1 - asr r1, r1, #1 - add r0, r0, r1 -_02201576: - bx lr - thumb_func_end ov16_02201554 - - thumb_func_start ov16_02201578 -ov16_02201578: ; 0x02201578 - ldrb r0, [r0, #0xb] - cmp r0, #3 - bne _02201582 - mov r0, #6 - bx lr -_02201582: - mov r0, #4 - bx lr - .balign 4, 0 - thumb_func_end ov16_02201578 - - thumb_func_start ov16_02201588 -ov16_02201588: ; 0x02201588 - ldrb r0, [r0, #0xb] - cmp r0, #4 - bne _02201592 - mov r0, #0xf - bx lr -_02201592: - mov r0, #0xa - bx lr - .balign 4, 0 - thumb_func_end ov16_02201588 - - thumb_func_start ov16_02201598 -ov16_02201598: ; 0x02201598 - push {r3, r4, r5, lr} - add r5, r0, #0 - bl ov16_02201578 - add r4, r0, #0 - add r0, r5, #0 - bl ov16_02201588 - add r1, r4, #3 - mul r0, r1 - add r0, r0, #1 - pop {r3, r4, r5, pc} - thumb_func_end ov16_02201598 - - thumb_func_start ov16_022015B0 -ov16_022015B0: ; 0x022015B0 - mov r2, #0xc - mul r2, r1 - add r0, r0, r2 - ldrb r0, [r0, #1] - bx lr - .balign 4, 0 - thumb_func_end ov16_022015B0 - - thumb_func_start ov16_022015BC -ov16_022015BC: ; 0x022015BC - mov r2, #0xc - mul r2, r1 - ldrb r0, [r0, r2] - bx lr - thumb_func_end ov16_022015BC - - thumb_func_start ov16_022015C4 -ov16_022015C4: ; 0x022015C4 - mov r2, #0xc - mul r2, r1 - add r0, r0, r2 - ldrb r0, [r0, #9] - cmp r0, #0 - bne _022015D4 - mov r0, #0 - bx lr -_022015D4: - cmp r0, #0x32 - bgt _022015DC - mov r0, #1 - bx lr -_022015DC: - mov r0, #2 - bx lr - thumb_func_end ov16_022015C4 - - thumb_func_start ov16_022015E0 -ov16_022015E0: ; 0x022015E0 - mov r2, #0xc - mul r2, r1 - add r0, r0, r2 - ldrb r0, [r0, #9] - bx lr - .balign 4, 0 - thumb_func_end ov16_022015E0 - - thumb_func_start ov16_022015EC -ov16_022015EC: ; 0x022015EC - mov r2, #0xc - mul r2, r1 - add r0, r0, r2 - ldrb r0, [r0, #0xa] - bx lr - .balign 4, 0 - thumb_func_end ov16_022015EC - - thumb_func_start ov16_022015F8 -ov16_022015F8: ; 0x022015F8 - mov r2, #0xc - mul r2, r1 - add r0, r0, r2 - ldrh r0, [r0, #2] - bx lr - .balign 4, 0 - thumb_func_end ov16_022015F8 - - thumb_func_start ov16_02201604 -ov16_02201604: ; 0x02201604 - mov r2, #0xc - mul r2, r1 - add r0, r0, r2 - ldrh r0, [r0, #4] - bx lr - .balign 4, 0 - thumb_func_end ov16_02201604 - - thumb_func_start ov16_02201610 -ov16_02201610: ; 0x02201610 - push {r4, r5, r6, lr} - add r5, r0, #0 - add r4, r1, #0 - mov r0, #0xc - mul r4, r0 - strb r3, [r5, r4] - mov r0, #1 - add r6, r5, r4 - strb r0, [r6, #1] - add r0, r2, #0 - ldrb r2, [r6, #0xb] - add r1, r3, #0 - bl ov16_02201528 - add r1, r6, #0 - strh r0, [r1, #2] - mov r0, #0 - strh r0, [r1, #4] - strb r0, [r1, #8] - strh r0, [r1, #6] - mov r0, #0x64 - strb r0, [r1, #9] - mov r0, #5 - strb r0, [r1, #0xa] - pop {r4, r5, r6, pc} - .balign 4, 0 - thumb_func_end ov16_02201610 - - thumb_func_start ov16_02201644 -ov16_02201644: ; 0x02201644 - mov r2, #0xc - mul r2, r1 - mov r3, #0x64 - add r0, r0, r2 - strb r3, [r0, #9] - bx lr - thumb_func_end ov16_02201644 - - thumb_func_start ov16_02201650 -ov16_02201650: ; 0x02201650 - mov r2, #0xc - mul r2, r1 - add r0, r0, r2 - ldrb r0, [r0, #0xb] - bx lr - .balign 4, 0 - thumb_func_end ov16_02201650 - - thumb_func_start ov16_0220165C -ov16_0220165C: ; 0x0220165C - mov r3, #0xc - mul r3, r1 - add r0, r0, r3 - strb r2, [r0, #0xb] - bx lr - .balign 4, 0 - thumb_func_end ov16_0220165C - - thumb_func_start ov16_02201668 -ov16_02201668: ; 0x02201668 - mov r2, #0xc - mul r2, r1 - add r0, r0, r2 - ldrh r0, [r0, #6] - bx lr - .balign 4, 0 - thumb_func_end ov16_02201668 - - thumb_func_start ov16_02201674 -ov16_02201674: ; 0x02201674 - push {r4, lr} - mov r2, #0xc - mul r2, r1 - add r0, r0, r2 - ldrh r4, [r0, #6] - bl ov16_022014FC - add r0, r4, #0 - pop {r4, pc} - .balign 4, 0 - thumb_func_end ov16_02201674 - - thumb_func_start ov16_02201688 -ov16_02201688: ; 0x02201688 - push {r4, lr} - add r4, r0, #0 - ldrb r2, [r4, #1] - cmp r2, #5 - bhi _022016F0 - add r3, r2, r2 - add r3, pc - ldrh r3, [r3, #6] - lsl r3, r3, #0x10 - asr r3, r3, #0x10 - add pc, r3 -_0220169E: ; jump table - .short _022016AA - _0220169E - 2 ; case 0 - .short _022016B0 - _0220169E - 2 ; case 1 - .short _022016B0 - _0220169E - 2 ; case 2 - .short _022016B0 - _0220169E - 2 ; case 3 - .short _022016B6 - _0220169E - 2 ; case 4 - .short _022016CE - _0220169E - 2 ; case 5 -_022016AA: - bl GF_AssertFail - pop {r4, pc} -_022016B0: - add r0, r2, #1 - strb r0, [r4, #1] - pop {r4, pc} -_022016B6: - bl ov16_02201514 - strh r0, [r4, #6] - ldrh r0, [r4, #6] - cmp r0, #2 - bhs _022016C6 - mov r0, #2 - strh r0, [r4, #6] -_022016C6: - ldrb r0, [r4, #1] - add r0, r0, #1 - strb r0, [r4, #1] - pop {r4, pc} -_022016CE: - mov r1, #0 - strh r1, [r4, #6] - mov r1, #2 - strb r1, [r4, #1] - mov r1, #5 - strb r1, [r4, #0xa] - ldrb r1, [r4, #8] - add r1, r1, #1 - strb r1, [r4, #8] - bl ov16_02201588 - ldrb r1, [r4, #8] - cmp r1, r0 - bne _022016F0 - add r0, r4, #0 - bl ov16_022014FC -_022016F0: - pop {r4, pc} - .balign 4, 0 - thumb_func_end ov16_02201688 - - thumb_func_start ov16_022016F4 -ov16_022016F4: ; 0x022016F4 - push {r3, r4, r5, r6, r7, lr} - add r5, r0, #0 - ldrb r0, [r5, #1] - add r7, r2, #0 - cmp r0, #5 - beq _0220175E - add r0, r1, #0 - ldrb r1, [r5] - ldrb r2, [r5, #0xb] - bl ov16_02201554 - add r6, r0, #0 - ldrh r0, [r5, #4] - mov r1, #0x3c - str r0, [sp] - add r0, r7, r0 - bl _s32_div_f - add r4, r0, #0 - ldr r0, [sp] - mov r1, #0x3c - add r0, r7, r0 - bl _s32_div_f - strh r1, [r5, #4] - cmp r4, #0 - beq _0220175E - ldrb r1, [r5, #9] - add r0, r6, #0 - mul r0, r4 - cmp r1, r0 - blt _0220173A - sub r0, r1, r0 - strb r0, [r5, #9] - pop {r3, r4, r5, r6, r7, pc} -_0220173A: - cmp r1, #0 - beq _0220174E - sub r0, r6, #1 - add r0, r1, r0 - add r1, r6, #0 - bl _s32_div_f - sub r4, r4, r0 - mov r0, #0 - strb r0, [r5, #9] -_0220174E: - ldrb r0, [r5, #0xa] - cmp r0, r4 - ble _0220175A - sub r0, r0, r4 - strb r0, [r5, #0xa] - pop {r3, r4, r5, r6, r7, pc} -_0220175A: - mov r0, #0 - strb r0, [r5, #0xa] -_0220175E: - pop {r3, r4, r5, r6, r7, pc} - thumb_func_end ov16_022016F4 - - thumb_func_start ov16_02201760 -ov16_02201760: ; 0x02201760 - push {r3, r4, r5, r6, r7, lr} - add r4, r0, #0 - mov r0, #0 - add r6, r1, #0 - add r7, r2, #0 - str r0, [sp] -_0220176C: - ldrb r1, [r4] - cmp r1, #0 - beq _022017EE - ldrb r0, [r4, #1] - cmp r0, #0 - beq _022017EE - ldrb r2, [r4, #0xb] - add r0, r6, #0 - bl ov16_02201528 - add r5, r0, #0 - add r0, r4, #0 - bl ov16_02201598 - mul r0, r5 - cmp r7, r0 - blt _02201796 - add r0, r4, #0 - bl ov16_022014FC - b _022017EE -_02201796: - add r5, r7, #0 - b _022017E4 -_0220179A: - ldrh r2, [r4, #2] - cmp r2, r5 - ble _022017B2 - add r0, r4, #0 - add r1, r6, #0 - add r2, r5, #0 - bl ov16_022016F4 - ldrh r0, [r4, #2] - sub r0, r0, r5 - strh r0, [r4, #2] - b _022017EE -_022017B2: - add r0, r4, #0 - add r1, r6, #0 - bl ov16_022016F4 - add r0, r4, #0 - add r1, r6, #0 - bl ov16_02201688 - ldrh r0, [r4, #2] - ldrb r1, [r4] - ldrb r2, [r4, #0xb] - sub r5, r5, r0 - add r0, r6, #0 - bl ov16_02201528 - strh r0, [r4, #2] - ldrb r0, [r4, #1] - cmp r0, #5 - bne _022017E4 - add r0, r4, #0 - bl ov16_02201578 - ldrh r1, [r4, #2] - mul r0, r1 - strh r0, [r4, #2] -_022017E4: - ldrb r0, [r4, #1] - cmp r0, #0 - beq _022017EE - cmp r5, #0 - bne _0220179A -_022017EE: - ldr r0, [sp] - add r4, #0xc - add r0, r0, #1 - str r0, [sp] - cmp r0, #4 - blt _0220176C - pop {r3, r4, r5, r6, r7, pc} - thumb_func_end ov16_02201760 - - thumb_func_start ov16_022017FC -ov16_022017FC: ; 0x022017FC - push {r0, r1, r2, r3} - push {r3, r4} - add r4, r0, #0 - add r3, sp, #0xc - add r2, r4, #0 - ldmia r3!, {r0, r1} - stmia r2!, {r0, r1} - ldmia r3!, {r0, r1} - stmia r2!, {r0, r1} - add r2, sp, #0x1c - ldmia r2!, {r0, r1} - add r4, #0x10 - stmia r4!, {r0, r1} - ldr r0, [r2] - str r0, [r4] - pop {r3, r4} - add sp, #0x10 - bx lr - thumb_func_end ov16_022017FC - - thumb_func_start ov16_02201820 -ov16_02201820: ; 0x02201820 - push {r4, r5} - add r5, r0, #0 - add r3, r5, #0 - add r4, r1, #0 - ldmia r3!, {r0, r1} - stmia r4!, {r0, r1} - ldmia r3!, {r0, r1} - add r5, #0x10 - stmia r4!, {r0, r1} - ldmia r5!, {r0, r1} - stmia r2!, {r0, r1} - ldr r0, [r5] - str r0, [r2] - pop {r4, r5} - bx lr - .balign 4, 0 - thumb_func_end ov16_02201820 - - thumb_func_start ov16_02201840 -ov16_02201840: ; 0x02201840 - ldr r3, _02201848 ; =NARC_New - add r1, r0, #0 - mov r0, #0x42 - bx r3 - .balign 4, 0 -_02201848: .word NARC_New - thumb_func_end ov16_02201840 - - thumb_func_start ov16_0220184C -ov16_0220184C: ; 0x0220184C - ldr r3, _02201850 ; =NARC_AllocAndReadWholeMember - bx r3 - .balign 4, 0 -_02201850: .word NARC_AllocAndReadWholeMember - thumb_func_end ov16_0220184C - - thumb_func_start ov16_02201854 -ov16_02201854: ; 0x02201854 - ldr r3, _02201858 ; =NARC_Delete - bx r3 - .balign 4, 0 -_02201858: .word NARC_Delete - thumb_func_end ov16_02201854 - - thumb_func_start ov16_0220185C -ov16_0220185C: ; 0x0220185C - cmp r1, #0xa - bhi _022018AE - add r1, r1, r1 - add r1, pc - ldrh r1, [r1, #6] - lsl r1, r1, #0x10 - asr r1, r1, #0x10 - add pc, r1 -_0220186C: ; jump table - .short _02201882 - _0220186C - 2 ; case 0 - .short _02201886 - _0220186C - 2 ; case 1 - .short _0220188A - _0220186C - 2 ; case 2 - .short _0220188E - _0220186C - 2 ; case 3 - .short _02201892 - _0220186C - 2 ; case 4 - .short _02201896 - _0220186C - 2 ; case 5 - .short _0220189A - _0220186C - 2 ; case 6 - .short _0220189E - _0220186C - 2 ; case 7 - .short _022018A2 - _0220186C - 2 ; case 8 - .short _022018A6 - _0220186C - 2 ; case 9 - .short _022018AA - _0220186C - 2 ; case 10 -_02201882: - ldrh r0, [r0] - bx lr -_02201886: - ldrb r0, [r0, #2] - bx lr -_0220188A: - ldrb r0, [r0, #3] - bx lr -_0220188E: - ldrb r0, [r0, #4] - bx lr -_02201892: - ldrb r0, [r0, #5] - bx lr -_02201896: - ldrb r0, [r0, #6] - bx lr -_0220189A: - ldrb r0, [r0, #7] - bx lr -_0220189E: - ldrb r0, [r0, #8] - bx lr -_022018A2: - ldrb r0, [r0, #9] - bx lr -_022018A6: - ldrb r0, [r0, #0xa] - bx lr -_022018AA: - ldrb r0, [r0, #0xb] - bx lr -_022018AE: - mov r0, #0 - bx lr - .balign 4, 0 - thumb_func_end ov16_0220185C - - thumb_func_start ov16_022018B4 -ov16_022018B4: ; 0x022018B4 - cmp r0, #0 - bne _022018BC - mov r0, #0 - bx lr -_022018BC: - add r0, #0x94 - lsl r0, r0, #0x10 - lsr r0, r0, #0x10 - bx lr - thumb_func_end ov16_022018B4 - - thumb_func_start ov16_022018C4 -ov16_022018C4: ; 0x022018C4 - cmp r0, #0 - bne _022018CC - mov r0, #0 - bx lr -_022018CC: - sub r0, #0x94 - lsl r0, r0, #0x10 - lsr r0, r0, #0x10 - bx lr - thumb_func_end ov16_022018C4 - - thumb_func_start ov16_022018D4 -ov16_022018D4: ; 0x022018D4 - cmp r0, #0 - bne _022018DC - mov r0, #0 - bx lr -_022018DC: - add r0, #0x5e - lsl r0, r0, #0x10 - lsr r0, r0, #0x10 - bx lr - thumb_func_end ov16_022018D4 - - thumb_func_start ov16_022018E4 -ov16_022018E4: ; 0x022018E4 - cmp r0, #0 - bne _022018EC - mov r0, #0 - bx lr -_022018EC: - sub r0, #0x5e - bx lr - thumb_func_end ov16_022018E4 - - thumb_func_start ov16_022018F0 -ov16_022018F0: ; 0x022018F0 - push {r3, r4, r5, r6, r7, lr} - mov r5, #0 - add r6, r0, #0 - add r7, r1, #0 - add r4, r5, #0 -_022018FA: - add r1, r4, #0 - add r1, #0x95 - lsl r1, r1, #0x10 - add r0, r6, #0 - lsr r1, r1, #0x10 - add r2, r7, #0 - bl Bag_GetQuantity - add r0, r5, r0 - lsl r0, r0, #0x10 - add r4, r4, #1 - lsr r5, r0, #0x10 - cmp r4, #0x40 - blt _022018FA - add r0, r5, #0 - pop {r3, r4, r5, r6, r7, pc} - .balign 4, 0 - thumb_func_end ov16_022018F0 - - thumb_func_start ov16_0220191C -ov16_0220191C: ; 0x0220191C - push {r3, r4, r5, r6, r7, lr} - mov r5, #0 - add r6, r0, #0 - add r7, r1, #0 - add r4, r5, #0 -_02201926: - add r1, r4, #0 - add r1, #0x5f - lsl r1, r1, #0x10 - add r0, r6, #0 - lsr r1, r1, #0x10 - add r2, r7, #0 - bl Bag_GetQuantity - add r0, r5, r0 - lsl r0, r0, #0x10 - add r4, r4, #1 - lsr r5, r0, #0x10 - cmp r4, #4 - blt _02201926 - add r0, r5, #0 - pop {r3, r4, r5, r6, r7, pc} - .balign 4, 0 - thumb_func_end ov16_0220191C - - thumb_func_start ov16_02201948 -ov16_02201948: ; 0x02201948 - push {r4, lr} - add r4, r0, #0 - ldr r0, [r4] - cmp r0, #0 - beq _02201968 - bl OverlayManager_Run - cmp r0, #0 - beq _02201968 - ldr r0, [r4] - bl OverlayManager_Delete - mov r0, #0 - str r0, [r4] - mov r0, #1 - pop {r4, pc} -_02201968: - mov r0, #0 - pop {r4, pc} - thumb_func_end ov16_02201948 - - thumb_func_start ov16_0220196C -ov16_0220196C: ; 0x0220196C - push {r3, r4, r5, lr} - add r5, r0, #0 - ldr r0, _022019B4 ; =FS_OVERLAY_ID(OVY_17) - mov r1, #2 - bl HandleLoadOverlay - bl ov17_02201BC0 - mov r2, #2 - mov r0, #3 - mov r1, #0x82 - lsl r2, r2, #0x10 - bl CreateHeap - add r0, r5, #0 - mov r1, #0x20 - mov r2, #0x82 - bl OverlayManager_CreateAndGetData - mov r1, #0 - mov r2, #0x20 - add r4, r0, #0 - bl MI_CpuFill8 - mov r0, #0x82 - str r0, [r4] - add r0, r5, #0 - bl OverlayManager_GetArgs - str r0, [r4, #4] - add r0, r4, #0 - bl ov16_02201A34 - mov r0, #1 - pop {r3, r4, r5, pc} - nop -_022019B4: .word FS_OVERLAY_ID(OVY_17) - thumb_func_end ov16_0220196C - - thumb_func_start ov16_022019B8 -ov16_022019B8: ; 0x022019B8 - push {r4, lr} - add r4, r1, #0 - bl OverlayManager_GetData - ldr r1, [r4] - cmp r1, #4 - bhi _02201A00 - add r1, r1, r1 - add r1, pc - ldrh r1, [r1, #6] - lsl r1, r1, #0x10 - asr r1, r1, #0x10 - add pc, r1 -_022019D2: ; jump table - .short _022019DC - _022019D2 - 2 ; case 0 - .short _022019E4 - _022019D2 - 2 ; case 1 - .short _022019EC - _022019D2 - 2 ; case 2 - .short _022019F4 - _022019D2 - 2 ; case 3 - .short _022019FC - _022019D2 - 2 ; case 4 -_022019DC: - bl ov16_02201A60 - str r0, [r4] - b _02201A00 -_022019E4: - bl ov16_02201A78 - str r0, [r4] - b _02201A00 -_022019EC: - bl ov16_02201AA0 - str r0, [r4] - b _02201A00 -_022019F4: - bl ov16_02201B24 - str r0, [r4] - b _02201A00 -_022019FC: - mov r0, #1 - pop {r4, pc} -_02201A00: - mov r0, #0 - pop {r4, pc} - thumb_func_end ov16_022019B8 - - thumb_func_start ov16_02201A04 -ov16_02201A04: ; 0x02201A04 - push {r3, r4, r5, lr} - add r5, r0, #0 - bl OverlayManager_GetData - add r4, r0, #0 - bl ov17_02201BC0 - add r0, r4, #0 - bl ov16_02201A4C - add r0, r5, #0 - bl OverlayManager_FreeData - mov r0, #0x82 - bl DestroyHeap - ldr r0, _02201A30 ; =FS_OVERLAY_ID(OVY_17) - bl UnloadOverlayByID - mov r0, #1 - pop {r3, r4, r5, pc} - nop -_02201A30: .word FS_OVERLAY_ID(OVY_17) - thumb_func_end ov16_02201A04 - - thumb_func_start ov16_02201A34 -ov16_02201A34: ; 0x02201A34 - push {r4, lr} - add r4, r0, #0 - ldr r0, [r4] - bl BagCursor_New - str r0, [r4, #0x18] - ldr r0, [r4] - bl BagCursor_New - str r0, [r4, #0x1c] - pop {r4, pc} - .balign 4, 0 - thumb_func_end ov16_02201A34 - - thumb_func_start ov16_02201A4C -ov16_02201A4C: ; 0x02201A4C - push {r4, lr} - add r4, r0, #0 - ldr r0, [r4, #0x1c] - bl FreeToHeap - ldr r0, [r4, #0x18] - bl FreeToHeap - pop {r4, pc} - .balign 4, 0 - thumb_func_end ov16_02201A4C - - thumb_func_start ov16_02201A60 -ov16_02201A60: ; 0x02201A60 - push {r4, lr} - add r4, r0, #0 - ldr r0, _02201A74 ; =ov16_02201B68 - ldr r2, [r4] - add r1, r4, #0 - bl OverlayManager_New - str r0, [r4, #8] - mov r0, #1 - pop {r4, pc} - .balign 4, 0 -_02201A74: .word ov16_02201B68 - thumb_func_end ov16_02201A60 - - thumb_func_start ov16_02201A78 -ov16_02201A78: ; 0x02201A78 - push {r4, lr} - add r4, r0, #0 - add r0, #8 - bl ov16_02201948 - cmp r0, #0 - bne _02201A8A - mov r0, #1 - pop {r4, pc} -_02201A8A: - ldrb r0, [r4, #0x14] - add r0, #0xff - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - cmp r0, #1 - bhi _02201A9A - mov r0, #2 - pop {r4, pc} -_02201A9A: - mov r0, #4 - pop {r4, pc} - .balign 4, 0 - thumb_func_end ov16_02201A78 - - thumb_func_start ov16_02201AA0 -ov16_02201AA0: ; 0x02201AA0 - push {r3, r4, lr} - sub sp, #4 - add r4, r0, #0 - ldr r0, [r4, #4] - ldr r0, [r0, #0xc] - bl Save_Bag_Get - ldrb r1, [r4, #0x14] - cmp r1, #1 - beq _02201ABA - cmp r1, #2 - beq _02201ADC - b _02201AFE -_02201ABA: - ldr r1, _02201B14 ; =_02201B60 - ldr r2, _02201B18 ; =_02201BA0 - str r1, [r2] - ldr r2, [r4] - bl Bag_CreateView - str r0, [r4, #0x10] - ldr r1, [r4, #4] - mov r2, #6 - ldr r0, [r1, #4] - str r0, [sp] - ldr r0, [r4, #0x10] - ldr r1, [r1, #0xc] - ldr r3, [r4, #0x1c] - bl sub_0207789C - b _02201B02 -_02201ADC: - ldr r1, _02201B1C ; =ov16_02201B64 - ldr r2, _02201B18 ; =_02201BA0 - str r1, [r2] - ldr r2, [r4] - bl Bag_CreateView - str r0, [r4, #0x10] - ldr r1, [r4, #4] - mov r2, #6 - ldr r0, [r1, #4] - str r0, [sp] - ldr r0, [r4, #0x10] - ldr r1, [r1, #0xc] - ldr r3, [r4, #0x18] - bl sub_0207789C - b _02201B02 -_02201AFE: - bl GF_AssertFail -_02201B02: - ldr r0, _02201B20 ; =ov16_02201B78 - ldr r1, [r4, #0x10] - ldr r2, [r4] - bl OverlayManager_New - str r0, [r4, #8] - mov r0, #3 - add sp, #4 - pop {r3, r4, pc} - .balign 4, 0 -_02201B14: .word _02201B60 -_02201B18: .word _02201BA0 -_02201B1C: .word ov16_02201B64 -_02201B20: .word ov16_02201B78 - thumb_func_end ov16_02201AA0 - - thumb_func_start ov16_02201B24 -ov16_02201B24: ; 0x02201B24 - push {r4, lr} - add r4, r0, #0 - add r0, #8 - bl ov16_02201948 - cmp r0, #0 - bne _02201B36 - mov r0, #3 - pop {r4, pc} -_02201B36: - ldr r0, [r4, #0x10] - bl sub_0207790C - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - cmp r0, #4 - bne _02201B4C - ldr r0, [r4, #0x10] - bl sub_02077904 - b _02201B4E -_02201B4C: - ldr r0, _02201B5C ; =0x0000FFFF -_02201B4E: - strh r0, [r4, #0x16] - ldr r0, [r4, #0x10] - bl FreeToHeap - mov r0, #0 - str r0, [r4, #0x10] - pop {r4, pc} - .balign 4, 0 -_02201B5C: .word 0x0000FFFF - thumb_func_end ov16_02201B24 - - .rodata - -_02201B60: - .byte 0x00, 0xFF, 0x00, 0x00 - -ov16_02201B64: ; 0x02201B64 - .byte 0x04, 0xFF, 0x00, 0x00 - -ov16_02201B68: ; 0x02201B68 - .word ov17_02201C10, ov17_02201C78, ov17_02201D04, 0xFFFFFFFF - -ov16_02201B78: ; 0x02201B78 - .word ov15_BagApp_Init, ov15_BagApp_Exec, ov15_BagApp_Exit, FS_OVERLAY_ID(OVY_15) - - .data - -_02201BA0: - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - ; 0x02201BC0 diff --git a/asm/overlay_16_data.s b/asm/overlay_16_data.s new file mode 100644 index 0000000000..68514c8f07 --- /dev/null +++ b/asm/overlay_16_data.s @@ -0,0 +1,7 @@ + .public unused_02201BA0 + + .data + +unused_02201BA0: + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 diff --git a/asm/overlay_17.s b/asm/overlay_17.s index 83d2237d80..e7172f9a38 100644 --- a/asm/overlay_17.s +++ b/asm/overlay_17.s @@ -249,13 +249,13 @@ _02201DA8: bl ov17_022023B0 ldr r0, [r5, #0xc] ldr r1, [r5] - bl ov16_022018F0 + bl GetTotalBerryQuantity add r1, r5, #0 add r1, #0x82 strh r0, [r1] ldr r0, [r5, #0xc] ldr r1, [r5] - bl ov16_0220191C + bl GetTotalMulchQuantity add r1, r5, #0 add r1, #0x84 strh r0, [r1] @@ -838,7 +838,7 @@ _0220220C: mul r0, r1 add r5, r2, r0 ldrb r0, [r2, r0] - bl ov16_022018B4 + bl BerryIdToItemId add r1, r0, #0 ldrb r2, [r5, #5] ldr r0, [r4, #0xc] @@ -1060,13 +1060,13 @@ ov17_022023B0: ; 0x022023B0 beq _02202438 ldr r0, [r4, #4] ldrh r0, [r0, #0x16] - bl ov16_022018E4 + bl ItemIdToMulchId add r1, r4, #0 add r1, #0x7c add r2, r0, #0 ldrb r1, [r1] ldr r0, [r4, #0x14] - bl ov16_0220165C + bl BerryPots_SetPotMulch add r0, r4, #0 mov r1, #1 add r0, #0x7b @@ -1080,7 +1080,7 @@ _022023F6: beq _02202438 ldr r0, [r4, #4] ldrh r0, [r0, #0x16] - bl ov16_022018C4 + bl ItemIdToBerryId add r1, r4, #0 add r1, #0x7c add r3, r0, #0 @@ -2044,7 +2044,7 @@ ov17_02202B58: ; 0x02202B58 mul r0, r6 add r4, r2, r0 ldr r0, [r5, #0x14] - bl ov16_02201644 + bl BerryPots_ResetPotMoisture add r0, r5, #0 bl ov17_0220387C add r0, r6, #3 @@ -2081,7 +2081,7 @@ ov17_02202B98: ; 0x02202B98 add r4, r6, r7 bl ov16_02201674 ldrb r0, [r6, r7] - bl ov16_022018B4 + bl BerryIdToItemId add r1, r0, #0 ldrb r2, [r4, #5] ldr r0, [r5, #0xc] @@ -3159,7 +3159,7 @@ ov17_02203460: ; 0x02203460 add r0, r5, r0 add r0, #0x20 ldrb r0, [r0] - bl ov16_022018B4 + bl BerryIdToItemId mov r1, #1 add r4, r0, #0 bl GetItemIndexMapping @@ -3526,7 +3526,7 @@ _0220371E: ; jump table .short _0220376C - _0220371E - 2 ; case 16 _02203740: ldrb r0, [r6, #4] - bl ov16_022018D4 + bl MulchIdToItemId add r2, r0, #0 add r0, r4, #0 add r0, #0xa0 @@ -3704,13 +3704,13 @@ _02203884: strb r1, [r0] ldr r0, [r6, #0x14] add r1, r4, #0 - bl ov16_022015BC + bl BerryPots_GetPotBerryId add r1, r5, #0 add r1, #0x20 strb r0, [r1] ldr r0, [r6, #0x14] add r1, r4, #0 - bl ov16_022015B0 + bl BerryPots_GetPotGrowthStage add r1, r5, #0 add r1, #0x21 strb r0, [r1] @@ -3722,13 +3722,13 @@ _02203884: strb r0, [r1] ldr r0, [r6, #0x14] add r1, r4, #0 - bl ov16_022015E0 + bl BerryPots_GetPotMoisture add r1, r5, #0 add r1, #0x23 strb r0, [r1] ldr r0, [r6, #0x14] add r1, r4, #0 - bl ov16_02201650 + bl BerryPots_GetPotMulch add r1, r5, #0 add r1, #0x24 strb r0, [r1] diff --git a/asm/unk_0203E348.s b/asm/unk_0203E348.s index 7f33ebaa25..26deca1d3d 100644 --- a/asm/unk_0203E348.s +++ b/asm/unk_0203E348.s @@ -1385,8 +1385,8 @@ sub_0203EC98: ; 0x0203EC98 _0203ECBC: .word _020FA384 thumb_func_end sub_0203EC98 - thumb_func_start CreateBerryPotsWork -CreateBerryPotsWork: ; 0x0203ECC0 + thumb_func_start BerryPotsArgs_New +BerryPotsArgs_New: ; 0x0203ECC0 push {r3, r4, r5, lr} add r5, r0, #0 mov r0, #0xb @@ -1413,7 +1413,7 @@ CreateBerryPotsWork: ; 0x0203ECC0 add r0, r4, #0 pop {r3, r4, r5, pc} .balign 4, 0 - thumb_func_end CreateBerryPotsWork + thumb_func_end BerryPotsArgs_New thumb_func_start sub_0203ECFC sub_0203ECFC: ; 0x0203ECFC diff --git a/include/bag_cursor.h b/include/bag_cursor.h index 2ecc772b6d..7a2160d7e9 100644 --- a/include/bag_cursor.h +++ b/include/bag_cursor.h @@ -1,6 +1,8 @@ #ifndef POKEHEARTGOLD_BAG_CURSOR_H #define POKEHEARTGOLD_BAG_CURSOR_H +#include "heap.h" + /* * Remembers the cursor position in the field bag view */ diff --git a/include/constants/items.h b/include/constants/items.h index 7a1a985c16..cd6481d9b2 100644 --- a/include/constants/items.h +++ b/include/constants/items.h @@ -385,6 +385,12 @@ #define ITEM_ODD_KEYSTONE 111 #define ITEM_GRISEOUS_ORB 112 +#define FIRST_MULCH_IDX ITEM_GROWTH_MULCH +#define LAST_MULCH_IDX ITEM_GOOEY_MULCH +#define NUM_MULCHES (LAST_MULCH_IDX - FIRST_MULCH_IDX + 1) +#define MULCH_IDX(mulch) ((mulch) - FIRST_MULCH_IDX + 1) +#define MULCH_NONE 0 + // Unused #define ITEM_UNUSED_113 113 #define ITEM_UNUSED_114 114 @@ -499,6 +505,8 @@ #define FIRST_BERRY_IDX ITEM_CHERI_BERRY #define LAST_BERRY_IDX ITEM_ROWAP_BERRY #define NUM_BERRIES (LAST_BERRY_IDX - FIRST_BERRY_IDX + 1) +#define BERRY_IDX(berry) ((berry) - FIRST_BERRY_IDX + 1) +#define BERRY_NONE 0 // Battle Held items #define ITEM_BRIGHTPOWDER 213 diff --git a/include/gf_rtc.h b/include/gf_rtc.h index fbc1ddc3b7..3ea5ec7d88 100644 --- a/include/gf_rtc.h +++ b/include/gf_rtc.h @@ -1,6 +1,8 @@ #ifndef POKEHEARTGOLD_GF_RTC_H #define POKEHEARTGOLD_GF_RTC_H +#include + typedef enum RTC_TimeOfDay { RTC_TIMEOFDAY_MORN = 0, RTC_TIMEOFDAY_DAY, diff --git a/include/heap.h b/include/heap.h index 60106fff76..d2739c4fd0 100644 --- a/include/heap.h +++ b/include/heap.h @@ -21,6 +21,7 @@ typedef enum HeapID { HEAP_ID_CREDITS = 73, HEAP_ID_89 = 89, HEAP_ID_GAME_BOARD = 110, + HEAP_ID_BERRY_POTS = 130, HEAP_ID_VOLTORB_FLIP = 160 } HeapID; diff --git a/include/overlay_16.h b/include/overlay_16.h new file mode 100644 index 0000000000..9cafccfd57 --- /dev/null +++ b/include/overlay_16.h @@ -0,0 +1,42 @@ +#ifndef POKEHEARTGOLD_OVERLAY_16_H +#define POKEHEARTGOLD_OVERLAY_16_H + +#include "bag.h" +#include "save_misc_data.h" +#include "overlay_manager.h" + +typedef struct UnkStruct_ov16_022014A0 { + u8 defaultGrowthTimeInHours; + u8 defaultDrainRate; + u8 unk2; // yield multiplier? +} UnkStruct_ov16_022014A0; // size: 0x3 + +UnkStruct_ov16_022014A0 *ov16_022014A0(HeapID heapId); +u8 BerryPots_GetPotGrowthStage(BerryPot *berryPots, u32 idx); +u8 BerryPots_GetPotBerryId(BerryPot *berryPots, u32 idx); +u32 ov16_022015C4(BerryPot *berryPots, u32 idx); +u8 BerryPots_GetPotMoisture(BerryPot *berryPots, u32 idx); +u8 ov16_022015EC(BerryPot *berryPots, u32 idx); +u16 ov16_022015F8(BerryPot *berryPots, u32 idx); +u16 ov16_02201604(BerryPot *berryPots, u32 idx); +void ov16_02201610(BerryPot *berryPots, u32 idx, UnkStruct_ov16_022014A0 *a2, u8 a3); +void BerryPots_ResetPotMoisture(BerryPot *berryPots, u32 idx); +u8 BerryPots_GetPotMulch(BerryPot *berryPots, u32 idx); +void BerryPots_SetPotMulch(BerryPot *berryPots, u32 idx, u8 mulch); +u16 ov16_02201668(BerryPot *berryPots, u32 idx); +u16 ov16_02201674(BerryPot *berryPots, u32 idx); +void ov16_02201760(BerryPot *berryPots, UnkStruct_ov16_022014A0 *a1, s32 a2); +void ov16_022017FC(struct GF_RTC_DateTime *dest, struct GF_RTC_DateTime src); +void ov16_02201820(struct GF_RTC_DateTime *datetime, RTCDate *date, RTCTime *time); +u16 BerryIdToItemId(u16 berryId); +u16 ItemIdToBerryId(u16 itemId); +u16 MulchIdToItemId(u16 mulchId); +u32 ItemIdToMulchId(u16 itemId); +u16 GetTotalBerryQuantity(Bag *bag, HeapID heapId); +u16 GetTotalMulchQuantity(Bag *bag, HeapID heapId); + +BOOL ov16_0220196C(OVY_MANAGER *manager, int *state); +BOOL ov16_022019B8(OVY_MANAGER *manager, int *state); +BOOL ov16_02201A04(OVY_MANAGER *manager, int *state); + +#endif diff --git a/include/save_misc_data.h b/include/save_misc_data.h index 4e45a18ca0..3c7fb0a911 100644 --- a/include/save_misc_data.h +++ b/include/save_misc_data.h @@ -13,11 +13,24 @@ typedef struct APRICORN_TREE { u16 unk_2; } APRICORN_TREE; -typedef struct BERRY_POT { - u8 unk_0; - u8 unk_1; - u8 filler_2[10]; -} BERRY_POT; +#define BERRY_POT_GROWTH_STAGE_INVALID 0 +#define BERRY_POT_GROWTH_STAGE_PLANTED 1 +#define BERRY_POT_GROWTH_STAGE_SPROUTED 2 +#define BERRY_POT_GROWTH_STAGE_GROWING 3 +#define BERRY_POT_GROWTH_STAGE_BLOOM 4 +#define BERRY_POT_GROWTH_STAGE_BERRIES 5 + +typedef struct BerryPot { + u8 berryId; + u8 growthStage; + u16 unk_2; + u16 unk_4; + u16 unk_6; + u8 unk_8; + u8 moisture; + u8 unk_A; + u8 mulch; +} BerryPot; #define MAX_APRICORN_TREE 128 #define NUM_APRICORN_TREE 31 @@ -26,7 +39,7 @@ typedef struct BERRY_POT { typedef struct SAVE_MISC_DATA { APRICORN_TREE apricorn_trees[MAX_APRICORN_TREE]; - BERRY_POT berry_pots[MAX_BERRY_POT]; + BerryPot berry_pots[MAX_BERRY_POT]; struct GF_RTC_DateTime berry_datetime; struct Gymmick gymmick; u16 rivalName[PLAYER_NAME_LENGTH + 1]; @@ -47,14 +60,14 @@ typedef struct SAVE_MISC_DATA { u8 dummy_02DD[3]; } SAVE_MISC_DATA; -void Save_BerryPots_Init(BERRY_POT *berryPot); +void Save_BerryPots_Init(BerryPot *berryPot); void Save_BerryPotRTC_Init(struct GF_RTC_DateTime *dateTime); u32 Save_Misc_sizeof(void); void Save_Misc_Init(SAVE_MISC_DATA *saveMiscData); SAVE_MISC_DATA *Save_Misc_Get(SaveData *saveData); const SAVE_MISC_DATA *Save_Misc_Const_Get(const SaveData *saveData); APRICORN_TREE *Save_FieldApricornTrees_Get(SaveData *saveData); -BERRY_POT *Save_BerryPots_Get(SaveData *saveData); +BerryPot *Save_BerryPots_Get(SaveData *saveData); struct GF_RTC_DateTime *Save_BerryPotRTC_Get(SaveData *saveData); struct Gymmick *Save_GetGymmickPtr(SaveData *saveData); const u16 *Save_Misc_RivalName_Const_Get(const SAVE_MISC_DATA *saveMiscData); diff --git a/include/unk_0203E348.h b/include/unk_0203E348.h index bbcc6025c9..45cafbe722 100644 --- a/include/unk_0203E348.h +++ b/include/unk_0203E348.h @@ -14,10 +14,16 @@ struct UseMailWork; struct ApricornBoxWork; struct PalPadWork; -struct BerryPotsWork; struct UnownReportWork; struct GracideaWork; +typedef struct BerryPotsArgs { + u8 unk0[4]; + u32 unk4; + BagCursor *cursor; + SaveData *savedata; +} BerryPotsArgs; + typedef struct PartyMenuAppData { Party *party; Bag *bag; @@ -90,7 +96,7 @@ typedef struct ScratchCardAppData { struct UseMailWork *CreateUseMailWork(FieldSystem *fsys, int kind, int mailId, HeapID heapId); struct ApricornBoxWork *CreateApricornBoxWork(FieldSystem *fsys, int a1); struct PalPadWork *CreatePalPadWork(FieldSystem *fsys, SaveData *saveData, HeapID heapId); -struct BerryPotsWork *CreateBerryPotsWork(FieldSystem *fsys); +struct BerryPotsArgs *BerryPotsArgs_New(FieldSystem *fsys); struct UnownReportWork *CreateUnownReportWork(FieldSystem *fsys); struct GracideaWork *sub_0203FAE8(FieldSystem *fsys, HeapID heapId, u16 itemId); PartyMenuAppData *sub_0203E580(HeapID heapId, FieldSystem *fsys); //todo: party select screen diff --git a/main.lsf b/main.lsf index d263532e81..39489504aa 100644 --- a/main.lsf +++ b/main.lsf @@ -605,7 +605,9 @@ Overlay OVY_15 Overlay OVY_16 { After OVY_15 - Object asm/overlay_16.o + Object src/overlay_16_022014A0.o + Object src/overlay_16_02201948.o + Object asm/overlay_16_data.o } Overlay OVY_17 { diff --git a/src/field_use_item.c b/src/field_use_item.c index 6d82cc970d..9f50c478f1 100644 --- a/src/field_use_item.c +++ b/src/field_use_item.c @@ -71,7 +71,7 @@ static BOOL ItemFieldUseFunc_ApricornBox(struct ItemFieldUseData *data); static struct ApricornBoxWork *_CreateApricornBoxWork(FieldSystem *fsys); static void ItemMenuUseFunc_BerryPots(struct ItemMenuUseData *data, const struct ItemCheckUseData *dat2); static BOOL ItemFieldUseFunc_BerryPots(struct ItemFieldUseData *data); -static struct BerryPotsWork *_CreateBerryPotsWork(FieldSystem *fsys); +static struct BerryPotsArgs *_BerryPotsArgs_New(FieldSystem *fsys); static void ItemMenuUseFunc_UnownReport(struct ItemMenuUseData *data, const struct ItemCheckUseData *dat2); static BOOL ItemFieldUseFunc_UnownReport(struct ItemFieldUseData *data); static struct UnownReportWork *_CreateUnownReportWork(FieldSystem *fsys); @@ -606,17 +606,17 @@ static struct ApricornBoxWork *_CreateApricornBoxWork(FieldSystem *fsys) { static void ItemMenuUseFunc_BerryPots(struct ItemMenuUseData *data, const struct ItemCheckUseData *dat2) { FieldSystem *fsys = TaskManager_GetFieldSystem(data->taskManager); struct BagViewAppWork *env = TaskManager_GetEnv(data->taskManager); - env->atexit_TaskEnv = CreateBerryPotsWork(fsys); + env->atexit_TaskEnv = BerryPotsArgs_New(fsys); sub_0203C8F0(env, sub_0203D718); } static BOOL ItemFieldUseFunc_BerryPots(struct ItemFieldUseData *data) { - RegisteredItem_CreateGoToAppTask(data, (FieldApplicationWorkCtor)_CreateBerryPotsWork, FALSE); + RegisteredItem_CreateGoToAppTask(data, (FieldApplicationWorkCtor)_BerryPotsArgs_New, FALSE); return TRUE; } -static struct BerryPotsWork *_CreateBerryPotsWork(FieldSystem *fsys) { - return CreateBerryPotsWork(fsys); +static struct BerryPotsArgs *_BerryPotsArgs_New(FieldSystem *fsys) { + return BerryPotsArgs_New(fsys); } static void ItemMenuUseFunc_UnownReport(struct ItemMenuUseData *data, const struct ItemCheckUseData *dat2) { diff --git a/src/overlay_16_022014A0.c b/src/overlay_16_022014A0.c new file mode 100644 index 0000000000..b7ecf9cde1 --- /dev/null +++ b/src/overlay_16_022014A0.c @@ -0,0 +1,379 @@ +#include "global.h" +#include "filesystem.h" +#include "gf_rtc.h" +#include "overlay_16.h" + +typedef struct BerryFile { + u16 sizeInMillimeters; + u8 firmness; + u8 unk3; // yield multiplier? + u8 defaultGrowthInterval; + u8 defaultDrainRate; + u8 spiciness; + u8 dryness; + u8 sweetness; + u8 bitterness; + u8 sourness; + u8 smoothness; +} BerryFile; // size: 0xc + +enum BerryAttr { + BERRY_ATTR_SIZE, + BERRY_ATTR_FIRMNESS, + BERRY_ATTR_UNK2, + BERRY_ATTR_GROWTH_INTERVAL, + BERRY_ATTR_DRAIN_RATE, + BERRY_ATTR_SPICINESS, + BERRY_ATTR_DRYNESS, + BERRY_ATTR_SWEETNESS, + BERRY_ATTR_BITTERNESS, + BERRY_ATTR_SOURNESS, + BERRY_ATTR_SMOOTHNESS, +}; + +static void BerryPot_Clear(BerryPot *berryPot); +static u32 ov16_02201514(BerryPot *berryPot, UnkStruct_ov16_022014A0 *a1); +static u32 CalculateBerryPotGrowthInterval(UnkStruct_ov16_022014A0 *a0, int berryId, int a2); +static u32 CalculateBerryPotDrainRate(UnkStruct_ov16_022014A0 *a0, int berryId, int a2); +static u32 ov16_02201578(BerryPot *berryPot); +static u32 ov16_02201588(BerryPot *berryPot); +static u32 ov16_02201598(BerryPot *berryPot); +static void ov16_02201688(BerryPot *berryPot, UnkStruct_ov16_022014A0 *a1); +static void ov16_022016F4(BerryPot *berryPot, UnkStruct_ov16_022014A0 *a1, int a2); +static NARC *GetBerryInfoNarc(HeapID heapId); +static BerryFile *GetBerryFileFromNarc(NARC *narc, s32 fileId, HeapID heapId); +static void FreeBerryInfoNarc(NARC *narc); +static u16 GetBerryAttr(BerryFile *unk, enum BerryAttr attr); + +UnkStruct_ov16_022014A0 *ov16_022014A0(HeapID heapId) { + UnkStruct_ov16_022014A0 *unk; + NARC *narc; + + narc = GetBerryInfoNarc(heapId); + unk = AllocFromHeap(heapId, NUM_BERRIES * sizeof(UnkStruct_ov16_022014A0)); + + for (int fileId = 0; fileId < NUM_BERRIES; fileId++) { + BerryFile *berryFile = GetBerryFileFromNarc(narc, fileId, heapId); + unk[fileId].defaultGrowthTimeInHours = GetBerryAttr(berryFile, BERRY_ATTR_GROWTH_INTERVAL); + unk[fileId].defaultDrainRate = GetBerryAttr(berryFile, BERRY_ATTR_DRAIN_RATE); + unk[fileId].unk2 = GetBerryAttr(berryFile, BERRY_ATTR_UNK2); + + FreeToHeap(berryFile); + } + + FreeBerryInfoNarc(narc); + + return unk; +} + +static void BerryPot_Clear(BerryPot *berryPot) { + berryPot->berryId = BERRY_NONE; + berryPot->growthStage = BERRY_POT_GROWTH_STAGE_INVALID; + berryPot->unk_2 = 0; + berryPot->unk_4 = 0; + berryPot->unk_8 = 0; + berryPot->unk_6 = 0; + berryPot->moisture = 0; + berryPot->unk_A = 0; + berryPot->mulch = MULCH_NONE; +} + +static u32 ov16_02201514(BerryPot *berryPot, UnkStruct_ov16_022014A0 *a1) { + return berryPot->unk_A * a1[berryPot->berryId - 1].unk2; +} + +static u32 CalculateBerryPotGrowthInterval(UnkStruct_ov16_022014A0 *a0, int berryId, int mulch) { + s32 growthTimeInMinutes = a0[berryId - 1].defaultGrowthTimeInHours * 60; + if (mulch == MULCH_IDX(ITEM_GROWTH_MULCH)) { + return (growthTimeInMinutes * 3) / 4; + } else if (mulch == MULCH_IDX(ITEM_DAMP_MULCH)) { + growthTimeInMinutes += (growthTimeInMinutes / 2); + } + return growthTimeInMinutes; +} + +static u32 CalculateBerryPotDrainRate(UnkStruct_ov16_022014A0 *a0, int berryId, int mulch) { + s32 drainRate = a0[berryId - 1].defaultDrainRate; + if (mulch == MULCH_IDX(ITEM_DAMP_MULCH)) { + return drainRate / 2; + } else if (mulch == MULCH_IDX(ITEM_GROWTH_MULCH)) { + drainRate += (drainRate / 2); + } + return drainRate; +} + +static u32 ov16_02201578(BerryPot *berryPot) { + return (berryPot->mulch == MULCH_IDX(ITEM_STABLE_MULCH)) ? 6 : 4; +} + +static u32 ov16_02201588(BerryPot *berryPot) { + return (berryPot->mulch == MULCH_IDX(ITEM_GOOEY_MULCH)) ? 15 : 10; +} + +static u32 ov16_02201598(BerryPot *berryPot) { + u32 unk1 = ov16_02201578(berryPot); + u32 unk2 = ov16_02201588(berryPot); + return (unk1 + 3) * unk2 + 1; +} + +u8 BerryPots_GetPotGrowthStage(BerryPot *berryPots, u32 idx) { + return berryPots[idx].growthStage; +} + +u8 BerryPots_GetPotBerryId(BerryPot *berryPots, u32 idx) { + return berryPots[idx].berryId; +} + +u32 ov16_022015C4(BerryPot *berryPots, u32 idx) { + s32 moisture = berryPots[idx].moisture; + if (moisture == 0) { + return 0; + } else if (moisture <= 50) { + return 1; + } else { + return 2; + } +} + +u8 BerryPots_GetPotMoisture(BerryPot *berryPots, u32 idx) { + return berryPots[idx].moisture; +} + +u8 ov16_022015EC(BerryPot *berryPots, u32 idx) { + return berryPots[idx].unk_A; +} + +u16 ov16_022015F8(BerryPot *berryPots, u32 idx) { + return berryPots[idx].unk_2; +} + +u16 ov16_02201604(BerryPot *berryPots, u32 idx) { + return berryPots[idx].unk_4; +} + +void ov16_02201610(BerryPot *berryPots, u32 idx, UnkStruct_ov16_022014A0 *a2, u8 berryId) { + berryPots[idx].berryId = berryId; + berryPots[idx].growthStage = BERRY_POT_GROWTH_STAGE_PLANTED; + berryPots[idx].unk_2 = CalculateBerryPotGrowthInterval(a2, berryId, berryPots[idx].mulch); + berryPots[idx].unk_4 = 0; + berryPots[idx].unk_8 = 0; + berryPots[idx].unk_6 = 0; + berryPots[idx].moisture = 100; + berryPots[idx].unk_A = 5; +} + +void BerryPots_ResetPotMoisture(BerryPot *berryPots, u32 idx) { + berryPots[idx].moisture = 100; +} + +u8 BerryPots_GetPotMulch(BerryPot *berryPots, u32 idx) { + return berryPots[idx].mulch; +} + +void BerryPots_SetPotMulch(BerryPot *berryPots, u32 idx, u8 mulch) { + berryPots[idx].mulch = mulch; +} + +u16 ov16_02201668(BerryPot *berryPots, u32 idx) { + return berryPots[idx].unk_6; +} + +u16 ov16_02201674(BerryPot *berryPots, u32 idx) { + u16 unk = berryPots[idx].unk_6; + BerryPot_Clear(&berryPots[idx]); + return unk; +} + +static void ov16_02201688(BerryPot *berryPot, UnkStruct_ov16_022014A0 *a1) { + switch (berryPot->growthStage) { + case BERRY_POT_GROWTH_STAGE_INVALID: + GF_ASSERT(FALSE); + return; + case BERRY_POT_GROWTH_STAGE_PLANTED: + case BERRY_POT_GROWTH_STAGE_SPROUTED: + case BERRY_POT_GROWTH_STAGE_GROWING: + berryPot->growthStage++; + return; + case BERRY_POT_GROWTH_STAGE_BLOOM: + berryPot->unk_6 = ov16_02201514(berryPot, a1); + if (berryPot->unk_6 < 2) { + berryPot->unk_6 = 2; + } + berryPot->growthStage++; + return; + case BERRY_POT_GROWTH_STAGE_BERRIES: + berryPot->unk_6 = 0; + berryPot->growthStage = BERRY_POT_GROWTH_STAGE_SPROUTED; + berryPot->unk_A = 5; + berryPot->unk_8++; + if (berryPot->unk_8 == ov16_02201588(berryPot)) { + BerryPot_Clear(berryPot); + } + return; + } +} + +static void ov16_022016F4(BerryPot *berryPot, UnkStruct_ov16_022014A0 *a1, int a2) { + if (berryPot->growthStage == BERRY_POT_GROWTH_STAGE_BERRIES) { + return; + } + + int drainRate = CalculateBerryPotDrainRate(a1, berryPot->berryId, berryPot->mulch); + int r4 = (a2 + berryPot->unk_4) / 60; + berryPot->unk_4 = (a2 + berryPot->unk_4) % 60; + if (r4 == 0) { + return; + } + + if (berryPot->moisture >= (drainRate * r4)) { + berryPot->moisture -= (r4 * drainRate); + return; + } + + if (berryPot->moisture != 0) { + r4 -= (berryPot->moisture + (drainRate - 1)) / drainRate; + berryPot->moisture = 0; + } + + if (berryPot->unk_A > r4) { + berryPot->unk_A -= r4; + return; + } + + berryPot->unk_A = 0; +} + +void ov16_02201760(BerryPot *berryPots, UnkStruct_ov16_022014A0 *a1, s32 a2) { + for (s32 i = 0; i < MAX_BERRY_POT; i++) { + if (berryPots[i].berryId == BERRY_NONE || berryPots[i].growthStage == BERRY_POT_GROWTH_STAGE_INVALID) { + continue; + } + + s32 growthInterval = CalculateBerryPotGrowthInterval(a1, berryPots[i].berryId, berryPots[i].mulch); + s32 unk = ov16_02201598(&berryPots[i]); + + if (a2 >= growthInterval * unk) { + BerryPot_Clear(&berryPots[i]); + continue; + } + + s32 a2Tmp = a2; + + while (berryPots[i].growthStage != BERRY_POT_GROWTH_STAGE_INVALID && a2Tmp != 0) { + if (berryPots[i].unk_2 > a2Tmp) { + ov16_022016F4(&berryPots[i], a1, a2Tmp); + berryPots[i].unk_2 -= a2Tmp; + break; + } + + ov16_022016F4(&berryPots[i], a1, berryPots[i].unk_2); + ov16_02201688(&berryPots[i], a1); + a2Tmp -= berryPots[i].unk_2; + berryPots[i].unk_2 = CalculateBerryPotGrowthInterval(a1, berryPots[i].berryId, berryPots[i].mulch); + if (berryPots[i].growthStage == BERRY_POT_GROWTH_STAGE_BERRIES) { + berryPots[i].unk_2 *= ov16_02201578(&berryPots[i]); + } + } + } +} + +void ov16_022017FC(struct GF_RTC_DateTime *dest, struct GF_RTC_DateTime src) { + dest->date = src.date; + dest->time = src.time; +} + +void ov16_02201820(struct GF_RTC_DateTime *datetime, RTCDate *date, RTCTime *time) { + *date = datetime->date; + *time = datetime->time; +} + +static NARC *GetBerryInfoNarc(HeapID heapId) { + return NARC_New(NARC_a_0_6_6, heapId); +} + +static BerryFile *GetBerryFileFromNarc(NARC *narc, s32 fileId, HeapID heapId) { + return NARC_AllocAndReadWholeMember(narc, fileId, heapId); +} + +static void FreeBerryInfoNarc(NARC *narc) { + NARC_Delete(narc); +} + +static u16 GetBerryAttr(BerryFile *unk, enum BerryAttr attr) { + switch (attr) { + case BERRY_ATTR_SIZE: + return unk->sizeInMillimeters; + case BERRY_ATTR_FIRMNESS: + return unk->firmness; + case BERRY_ATTR_UNK2: + return unk->unk3; + case BERRY_ATTR_GROWTH_INTERVAL: + return unk->defaultGrowthInterval; + case BERRY_ATTR_DRAIN_RATE: + return unk->defaultDrainRate; + case BERRY_ATTR_SPICINESS: + return unk->spiciness; + case BERRY_ATTR_DRYNESS: + return unk->dryness; + case BERRY_ATTR_SWEETNESS: + return unk->sweetness; + case BERRY_ATTR_BITTERNESS: + return unk->bitterness; + case BERRY_ATTR_SOURNESS: + return unk->sourness; + case BERRY_ATTR_SMOOTHNESS: + return unk->smoothness; + default: + return 0; + } +} + +u16 BerryIdToItemId(u16 berryId) { + if (berryId == BERRY_NONE) { + return ITEM_NONE; + } + + return berryId + FIRST_BERRY_IDX - 1; +} + +u16 ItemIdToBerryId(u16 itemId) { + if (itemId == ITEM_NONE) { + return BERRY_NONE; + } + + return itemId - FIRST_BERRY_IDX + 1; +} + +u16 MulchIdToItemId(u16 mulchId) { + if (mulchId == MULCH_NONE) { + return ITEM_NONE; + } + + return mulchId + ITEM_GROWTH_MULCH - 1; +} + +u32 ItemIdToMulchId(u16 itemId) { + if (itemId == ITEM_NONE) { + return MULCH_NONE; + } + + return itemId - ITEM_GROWTH_MULCH + 1; +} + +u16 GetTotalBerryQuantity(Bag *bag, HeapID heapId) { + s32 i; + u16 total; + for (total = 0, i = 0; i < NUM_BAG_BERRIES; i++) { + total += Bag_GetQuantity(bag, FIRST_BERRY_IDX + i, heapId); + } + return total; +} + +u16 GetTotalMulchQuantity(Bag *bag, HeapID heapId) { + s32 i; + u16 total; + for (total = 0, i = 0; i < NUM_MULCHES; i++) { + total += Bag_GetQuantity(bag, ITEM_GROWTH_MULCH + i, heapId); + } + return total; +} diff --git a/src/overlay_16_02201948.c b/src/overlay_16_02201948.c new file mode 100644 index 0000000000..56b241030c --- /dev/null +++ b/src/overlay_16_02201948.c @@ -0,0 +1,187 @@ +#include "global.h" +#include "constants/items.h" +#include "bag_cursor.h" +#include "overlay_16.h" +#include "unk_0203E348.h" + +FS_EXTERN_OVERLAY(OVY_15); +FS_EXTERN_OVERLAY(OVY_17); + +extern BOOL ov15_BagApp_Init(OVY_MANAGER*, int*); +extern BOOL ov15_BagApp_Exec(OVY_MANAGER*, int*); +extern BOOL ov15_BagApp_Exit(OVY_MANAGER*, int*); + +extern BOOL ov17_02201C10(OVY_MANAGER*, int*); +extern BOOL ov17_02201C78(OVY_MANAGER*, int*); +extern BOOL ov17_02201D04(OVY_MANAGER*, int*); + +extern void ov17_02201BC0(void); + +static const u8 ov16_02201B60[] = { + POCKET_ITEMS, 0xFF +}; + +static const u8 ov16_02201B64[] = { + POCKET_BERRIES, 0xFF +}; + +static const OVY_MGR_TEMPLATE ov16_02201B68 = { + .init = ov17_02201C10, + .exec = ov17_02201C78, + .exit = ov17_02201D04, + .ovy_id = FS_OVERLAY_ID_NONE, +}; + +static const OVY_MGR_TEMPLATE ov16_02201B78 = { + .init = ov15_BagApp_Init, + .exec = ov15_BagApp_Exec, + .exit = ov15_BagApp_Exit, + .ovy_id = FS_OVERLAY_ID(OVY_15), +}; + +extern u8* unused_02201BA0; + +typedef struct UnkStruct_ov16_0220196C { + HeapID heapId; + BerryPotsArgs *args; + OVY_MANAGER *ovyManager; + u8 unkC[0x10 - 0xC]; + BagView *bagView; + u8 unk14; + u16 unk16; + BagCursor *cursor1; + BagCursor *cursor2; +} UnkStruct_ov16_0220196C; // size: 0x20 + +static BOOL ov16_02201948(OVY_MANAGER **manager); +static void ov16_02201A34(UnkStruct_ov16_0220196C *unk); +static void ov16_02201A4C(UnkStruct_ov16_0220196C *unk); +static u32 ov16_02201A60(UnkStruct_ov16_0220196C *unk); +static u32 ov16_02201A78(UnkStruct_ov16_0220196C *unk); +static u32 ov16_02201AA0(UnkStruct_ov16_0220196C *unk); +static u32 ov16_02201B24(UnkStruct_ov16_0220196C *unk); + +static BOOL ov16_02201948(OVY_MANAGER **manager) { + if (*manager != NULL && OverlayManager_Run(*manager)) { + OverlayManager_Delete(*manager); + *manager = NULL; + return TRUE; + } + + return FALSE; +} + +BOOL ov16_0220196C(OVY_MANAGER *manager, int *state) { + HandleLoadOverlay(FS_OVERLAY_ID(OVY_17), OVY_LOAD_ASYNC); + ov17_02201BC0(); + + CreateHeap(HEAP_ID_3, HEAP_ID_BERRY_POTS, 0x20000); + + UnkStruct_ov16_0220196C *unk = OverlayManager_CreateAndGetData(manager, sizeof(UnkStruct_ov16_0220196C), HEAP_ID_BERRY_POTS); + MI_CpuFill8(unk, 0, sizeof(UnkStruct_ov16_0220196C)); + unk->heapId = HEAP_ID_BERRY_POTS; + unk->args = OverlayManager_GetArgs(manager); + ov16_02201A34(unk); + + return TRUE; +} + +BOOL ov16_022019B8(OVY_MANAGER *manager, int *state) { + UnkStruct_ov16_0220196C *unk = OverlayManager_GetData(manager); + + switch (*state) { + case 0: + *state = ov16_02201A60(unk); + break; + case 1: + *state = ov16_02201A78(unk); + break; + case 2: + *state = ov16_02201AA0(unk); + break; + case 3: + *state = ov16_02201B24(unk); + break; + case 4: + return TRUE; + } + + return FALSE; +} + +BOOL ov16_02201A04(OVY_MANAGER *manager, int *state) { + UnkStruct_ov16_0220196C *unk = OverlayManager_GetData(manager); + ov17_02201BC0(); + + ov16_02201A4C(unk); + + OverlayManager_FreeData(manager); + DestroyHeap(HEAP_ID_BERRY_POTS); + UnloadOverlayByID(FS_OVERLAY_ID(OVY_17)); + + return TRUE; +} + +static void ov16_02201A34(UnkStruct_ov16_0220196C *unk) { + unk->cursor1 = BagCursor_New(unk->heapId); + unk->cursor2 = BagCursor_New(unk->heapId); +} + +static void ov16_02201A4C(UnkStruct_ov16_0220196C *unk) { + FreeToHeap(unk->cursor2); + FreeToHeap(unk->cursor1); +} + +static u32 ov16_02201A60(UnkStruct_ov16_0220196C *unk) { + unk->ovyManager = OverlayManager_New(&ov16_02201B68, unk, unk->heapId); + return 1; +} + +static u32 ov16_02201A78(UnkStruct_ov16_0220196C *unk) { + if (!ov16_02201948(&unk->ovyManager)) { + return 1; + } + + if ((u8)(unk->unk14 + 0xFF) <= 1) { + return 2; + } + + return 4; +} + +static u32 ov16_02201AA0(UnkStruct_ov16_0220196C *unk) { + Bag *bag = Save_Bag_Get(unk->args->savedata); + + switch (unk->unk14) { + case 1: + unused_02201BA0 = (u8*)ov16_02201B60; + + unk->bagView = Bag_CreateView(bag, ov16_02201B60, unk->heapId); + sub_0207789C(unk->bagView, unk->args->savedata, 6, unk->cursor2, unk->args->unk4); + break; + case 2: + unused_02201BA0 = (u8*)ov16_02201B64; + + unk->bagView = Bag_CreateView(bag, ov16_02201B64, unk->heapId); + sub_0207789C(unk->bagView, unk->args->savedata, 6, unk->cursor1, unk->args->unk4); + break; + default: + GF_ASSERT(FALSE); + break; + } + + unk->ovyManager = OverlayManager_New(&ov16_02201B78, unk->bagView, unk->heapId); + return 3; +} + +static u32 ov16_02201B24(UnkStruct_ov16_0220196C *unk) { + if (!ov16_02201948(&unk->ovyManager)) { + return 3; + } + + unk->unk16 = ((u8)sub_0207790C(unk->bagView) == 4) ? sub_02077904(unk->bagView) : 0xFFFF; + FreeToHeap(unk->bagView); + unk->bagView = NULL; + + return 0; +} diff --git a/src/save_misc.c b/src/save_misc.c index a6b009fcae..edb1f4ff9d 100644 --- a/src/save_misc.c +++ b/src/save_misc.c @@ -6,13 +6,13 @@ #include "msgdata/msg/msg_0295.h" #include "msgdata/msg/msg_0287.h" -void Save_BerryPots_Init(BERRY_POT *berryPot) { +void Save_BerryPots_Init(BerryPot *berryPots) { int i; - MI_CpuClear8(berryPot, MAX_BERRY_POT * sizeof(BERRY_POT)); + MI_CpuClear8(berryPots, MAX_BERRY_POT * sizeof(BerryPot)); for (i = 0; i < MAX_BERRY_POT; i++) { - berryPot[i].unk_1 = 0; - berryPot[i].unk_0 = 0; + berryPots[i].growthStage = BERRY_POT_GROWTH_STAGE_INVALID; + berryPots[i].berryId = 0; } } @@ -58,7 +58,7 @@ APRICORN_TREE *Save_FieldApricornTrees_Get(SaveData *saveData) { return misc->apricorn_trees; } -BERRY_POT *Save_BerryPots_Get(SaveData *saveData) { +BerryPot *Save_BerryPots_Get(SaveData *saveData) { SAVE_MISC_DATA *misc; misc = SaveArray_Get(saveData, SAVE_MISC); return misc->berry_pots;