From 7e1755ddf8cf489497599be94cbb39f745976be6 Mon Sep 17 00:00:00 2001 From: cecilarmitais Date: Sun, 13 Sep 2026 00:32:46 -0700 Subject: [PATCH] Decompile 11 more callees; give them headers and drop 40 call-site declarations Each function was verified at score 0 against its NORTH_AMERICA, EUROPE and JAPAN targets before landing, with the address walk closing exactly in each region, and by a matching US build after. main_020517D4.c GetRankUpEntry main_02001188.c MemAlloc main_0203088C.c CloseAdvancedTextBox main_020114F8.c ApplyGummiBoostsToGroundMonster main_0205283C.c GetExp overlay_29_02305C04.c EndNegativeStatusConditionWrapper overlay_29_02338350.c NearbyAllyIqSkillIsEnabled overlay_29_022E9FC0.c AdvanceFrame overlay_29_022E99F0.c TickStatusTurnCounter overlay_29_0234B4BC.c LogMessageByIdWithPopup overlay_29_0234B340.c LogMessageByIdWithPopupCheckUserTarget All eleven sat at the head or tail of their .s, so every one merges into the adjacent source file and no assembly file is split. Forty call-site declarations of these functions are replaced by an include of the owning header. Two of them disagreed with the real signature, and one had to be fixed for the tree to compile at all: MemAlloc was declared six different ways. src/overlay_24_end.c spelled it `void* MemAlloc(s32, s32);` -- signed -- and that file already includes main_02001188.h, so the contradiction became a hard compile error the moment MemAlloc had a header to contradict. It had been harmless only because the function had none. AdvanceFrame was declared `void AdvanceFrame(u8);` in two overlay_31 files against the real u32. Byte-neutral in practice, since every call site passes the literal 0x62, but wrong. struct unk_020517F4 was defined file-locally in src/main_0203D538.c. It now has one definition, in include/main_020517D4.h, and both local copies are gone -- otherwise including that header where GetRankUpEntry is called would collide. Two generated headers are made self-contained. extract_function.py emits a header that names types it does not include, and since the .c includes it first, the prototype builds its own scoped tag: include/main_020114F8.h declaring `struct ground_monster *` before common.h defines it made the definition read as a redeclaration with a different type. Authored by Claude (Opus 5) under human direction. Confirmed by a matching build: build/pmdsky.us/pmdsky.us.nds: OK. Co-Authored-By: Claude Opus 5 --- asm/include/main_02000DE0.inc | 9 ++--- .../{main_02011528.inc => main_02011554.inc} | 2 +- .../{main_020308A0.inc => main_020308C4.inc} | 2 - .../{main_020517F4.inc => main_02051804.inc} | 7 ++-- ...9_022E9A44.inc => overlay_29_022E9A6C.inc} | 0 ...9_022E9FE0.inc => overlay_29_022EA008.inc} | 12 +++--- ...9_02305C28.inc => overlay_29_02305C3C.inc} | 0 ...9_0234B350.inc => overlay_29_0234B3A4.inc} | 2 +- asm/main_02000DE0.s | 11 ----- asm/{main_02011528.s => main_02011554.s} | 17 +------- asm/{main_020308A0.s => main_020308C4.s} | 15 +------ asm/{main_020517F4.s => main_02051804.s} | 11 +---- ...ay_29_022E9A44.s => overlay_29_022E9A6C.s} | 16 +------- ...ay_29_022E9FE0.s => overlay_29_022EA008.s} | 18 +-------- ...ay_29_02305C28.s => overlay_29_02305C3C.s} | 11 +---- asm/overlay_29_02337EC0.s | 12 ------ ...ay_29_0234B350.s => overlay_29_0234B3A4.s} | 40 +------------------ include/main_02001188.h | 1 + include/main_020114F8.h | 3 ++ include/main_0203088C.h | 1 + include/main_020517D4.h | 8 ++++ include/overlay_29_022E99F0.h | 1 + include/overlay_29_022E9FC0.h | 1 + include/overlay_29_02305C04.h | 1 + include/overlay_29_02338350.h | 1 + include/overlay_29_0234B340.h | 1 + include/overlay_29_0234B4BC.h | 1 + main.lsf | 14 +++---- src/directory_file.c | 2 +- src/directory_file_mngr.c | 2 +- src/dungeon_projectile_throw.c | 4 +- src/ground_bg.c | 1 - src/main_02001188.c | 7 ++++ src/main_020114F8.c | 9 +++++ src/main_0203088C.c | 9 +++++ src/main_0203D538.c | 9 +---- src/main_02042B84.c | 1 - src/main_020517D4.c | 7 ++++ src/main_02051FF0.c | 2 +- src/main_0205D11C.c | 1 - src/move_orb_effects.c | 2 +- src/overlay_10_022BFD58.c | 2 +- src/overlay_11_02307334.c | 4 +- src/overlay_13_EntryOverlay13.c | 1 - src/overlay_15_0238A140.c | 2 +- src/overlay_24_end.c | 1 - src/overlay_25_init.c | 2 +- src/overlay_29_022DEAB0.c | 2 +- src/overlay_29_022E99F0.c | 12 ++++++ src/overlay_29_022E9FC0.c | 13 ++++++ src/overlay_29_022F0EDC.c | 2 +- src/overlay_29_02305C04.c | 7 ++++ src/overlay_29_023061A8.c | 2 +- src/overlay_29_02308FBC.c | 8 ++-- src/overlay_29_0230BBAC.c | 4 +- src/overlay_29_02311010.c | 4 +- src/overlay_29_0231CBC8.c | 4 +- src/overlay_29_02326188.c | 2 +- src/overlay_29_02329664.c | 2 +- src/overlay_29_0232A480.c | 2 +- src/overlay_29_0232CE40.c | 2 +- src/overlay_29_0232D368.c | 2 +- src/overlay_29_02338350.c | 7 ++++ src/overlay_29_0234B340.c | 15 +++++++ src/overlay_29_0234B4BC.c | 6 +++ src/overlay_29_0234BA54.c | 2 +- src/overlay_31_02382820.c | 3 +- src/overlay_31_02383880.c | 2 +- src/type_effectiveness.c | 2 +- 69 files changed, 174 insertions(+), 217 deletions(-) rename asm/include/{main_02011528.inc => main_02011554.inc} (100%) rename asm/include/{main_020308A0.inc => main_020308C4.inc} (79%) rename asm/include/{main_020517F4.inc => main_02051804.inc} (95%) rename asm/include/{overlay_29_022E9A44.inc => overlay_29_022E9A6C.inc} (100%) rename asm/include/{overlay_29_022E9FE0.inc => overlay_29_022EA008.inc} (100%) rename asm/include/{overlay_29_02305C28.inc => overlay_29_02305C3C.inc} (100%) rename asm/include/{overlay_29_0234B350.inc => overlay_29_0234B3A4.inc} (100%) rename asm/{main_02011528.s => main_02011554.s} (93%) rename asm/{main_020308A0.s => main_020308C4.s} (88%) rename asm/{main_020517F4.s => main_02051804.s} (98%) rename asm/{overlay_29_022E9A44.s => overlay_29_022E9A6C.s} (96%) rename asm/{overlay_29_022E9FE0.s => overlay_29_022EA008.s} (97%) rename asm/{overlay_29_02305C28.s => overlay_29_02305C3C.s} (96%) rename asm/{overlay_29_0234B350.s => overlay_29_0234B3A4.s} (65%) diff --git a/asm/include/main_02000DE0.inc b/asm/include/main_02000DE0.inc index d695cb95..ad918cfa 100644 --- a/asm/include/main_02000DE0.inc +++ b/asm/include/main_02000DE0.inc @@ -1,4 +1,8 @@ #pragma once +.public DEFAULT_MEMORY_ARENA_MEMORY +.public Debug_FatalError +.public Debug_Print0 +.public MEMORY_ALLOCATION_ARENA_GETTERS .public _02090B40 .public _02090B70 .public _02090BA0 @@ -7,11 +11,6 @@ .public _020B3384 .public _020B33A0 .public _020B33C0 -.public Debug_FatalError -.public Debug_Print0 -.public DEFAULT_MEMORY_ARENA_MEMORY -.public MemLocateSet -.public MEMORY_ALLOCATION_ARENA_GETTERS .public sub_02002C40 .public sub_02002CAC .public sub_02002CB4 diff --git a/asm/include/main_02011528.inc b/asm/include/main_02011554.inc similarity index 100% rename from asm/include/main_02011528.inc rename to asm/include/main_02011554.inc index bc33df29..390cce2b 100644 --- a/asm/include/main_02011528.inc +++ b/asm/include/main_02011554.inc @@ -1,9 +1,9 @@ #pragma once .public ApplyGummiBoostsGroundMode .public CALCIUM_STAT_BOOST +.public GINSENG_CHANCE_3 .public GetMoveBasePowerGround .public GetMoveMaxGinsengBoostGround -.public GINSENG_CHANCE_3 .public IRON_STAT_BOOST .public LIFE_SEED_HP_BOOST .public ModifyDefensiveStat diff --git a/asm/include/main_020308A0.inc b/asm/include/main_020308C4.inc similarity index 79% rename from asm/include/main_020308A0.inc rename to asm/include/main_020308C4.inc index 3c7c1302..a322e73c 100644 --- a/asm/include/main_020308A0.inc +++ b/asm/include/main_020308C4.inc @@ -1,8 +1,6 @@ #pragma once -.public DeleteWindow .public GetSelectedItemOnPage .public GetSelectedMenuItemIdx .public GetWindowContents -.public MemFree .public sub_020289B8 .public sub_02028A08 diff --git a/asm/include/main_020517F4.inc b/asm/include/main_02051804.inc similarity index 95% rename from asm/include/main_020517F4.inc rename to asm/include/main_02051804.inc index 99c325f2..21dcdd81 100644 --- a/asm/include/main_020517F4.inc +++ b/asm/include/main_02051804.inc @@ -1,13 +1,12 @@ #pragma once -.public _020B09B0 .public CopyColorToPaletteDataRgba +.public MTi_CpuClear32 +.public MTi_CpuCopy32 .public MarkPaletteDataAsNeedingUpdate .public MemAlloc .public MemFree .public MemZero -.public MTi_CpuClear32 -.public MTi_CpuCopy32 -.public RANK_UP_TABLE +.public _020B09B0 .public sub_0200302C .public sub_020030FC .public sub_0200A124 diff --git a/asm/include/overlay_29_022E9A44.inc b/asm/include/overlay_29_022E9A6C.inc similarity index 100% rename from asm/include/overlay_29_022E9A44.inc rename to asm/include/overlay_29_022E9A6C.inc diff --git a/asm/include/overlay_29_022E9FE0.inc b/asm/include/overlay_29_022EA008.inc similarity index 100% rename from asm/include/overlay_29_022E9FE0.inc rename to asm/include/overlay_29_022EA008.inc index 1863674a..56fb91ea 100644 --- a/asm/include/overlay_29_022E9FE0.inc +++ b/asm/include/overlay_29_022EA008.inc @@ -1,11 +1,10 @@ #pragma once -.public _s32_div_f .public ChangeSimpleObjTexture -.public DisplayMonstersAndItems -.public DisplayUi .public DUNGEON_BUTTON_INPUT .public DUNGEON_FRAMES_PASSED .public DUNGEON_PTR +.public DisplayMonstersAndItems +.public DisplayUi .public FlashLeaderIcon .public GetAlertBoxLoadingStatus .public GetBottomScreenOption @@ -14,6 +13,10 @@ .public HandleTopScreenFades .public InitWeirdMinimapMatrix .public OBJ_GRAPHICS_CONTROLS_PTR +.public RenderWeather3D +.public UpdateCamera +.public UpdateMinimap +.public _s32_div_f .public ov29_022DD8B4 .public ov29_022DDEF8 .public ov29_022DE11C @@ -30,7 +33,4 @@ .public ov29_0234B854 .public ov29_02353540 .public ov29_02353560 -.public RenderWeather3D .public sub_02051E20 -.public UpdateCamera -.public UpdateMinimap diff --git a/asm/include/overlay_29_02305C28.inc b/asm/include/overlay_29_02305C3C.inc similarity index 100% rename from asm/include/overlay_29_02305C28.inc rename to asm/include/overlay_29_02305C3C.inc diff --git a/asm/include/overlay_29_0234B350.inc b/asm/include/overlay_29_0234B3A4.inc similarity index 100% rename from asm/include/overlay_29_0234B350.inc rename to asm/include/overlay_29_0234B3A4.inc index 5eec7f07..c84645b1 100644 --- a/asm/include/overlay_29_0234B350.inc +++ b/asm/include/overlay_29_0234B3A4.inc @@ -1,5 +1,5 @@ #pragma once .public LogMessage -.public ov29_022E2CA0 .public ShouldDisplayEntityWrapper .public StringFromId +.public ov29_022E2CA0 diff --git a/asm/main_02000DE0.s b/asm/main_02000DE0.s index 6c525705..26a093c2 100644 --- a/asm/main_02000DE0.s +++ b/asm/main_02000DE0.s @@ -283,14 +283,3 @@ _02001148: _02001168: .word _02090B40 _0200116C: .word _02090BA0 arm_func_end SplitMemBlock - - arm_func_start MemAlloc -MemAlloc: ; 0x02001170 - ldr ip, _02001184 ; =MemLocateSet - mov r2, r1 - mov r1, r0 - mov r0, #0 - bx ip - .align 2, 0 -_02001184: .word MemLocateSet - arm_func_end MemAlloc diff --git a/asm/main_02011528.s b/asm/main_02011554.s similarity index 93% rename from asm/main_02011528.s rename to asm/main_02011554.s index 10af6256..12b4a031 100644 --- a/asm/main_02011528.s +++ b/asm/main_02011554.s @@ -1,23 +1,8 @@ .include "asm/macros.inc" - .include "main_02011528.inc" + .include "main_02011554.inc" .text - arm_func_start ApplyGummiBoostsToGroundMonster -ApplyGummiBoostsToGroundMonster: ; 0x02011528 - stmdb sp!, {lr} - sub sp, sp, #0xc - mov ip, r0 - stmia sp, {r1, r2, r3} - add r0, ip, #4 - add r1, ip, #8 - add r2, ip, #0xc - add r3, ip, #0xe - bl ApplyGummiBoostsGroundMode - add sp, sp, #0xc - ldmia sp!, {pc} - arm_func_end ApplyGummiBoostsToGroundMonster - arm_func_start ApplyGummiBoostsToTeamMember ApplyGummiBoostsToTeamMember: ; 0x02011554 stmdb sp!, {lr} diff --git a/asm/main_020308A0.s b/asm/main_020308C4.s similarity index 88% rename from asm/main_020308A0.s rename to asm/main_020308C4.s index 885dfa3d..d52d5fec 100644 --- a/asm/main_020308A0.s +++ b/asm/main_020308C4.s @@ -1,21 +1,8 @@ .include "asm/macros.inc" - .include "main_020308A0.inc" + .include "main_020308C4.inc" .text - arm_func_start CloseAdvancedTextBox -CloseAdvancedTextBox: ; 0x020308A0 - stmdb sp!, {r3, r4, r5, lr} - mov r5, r0 - bl GetWindowContents - mov r4, r0 - mov r0, r5 - bl DeleteWindow - mov r0, r4 - bl MemFree - ldmia sp!, {r3, r4, r5, pc} - arm_func_end CloseAdvancedTextBox - arm_func_start IsAdvancedTextBoxActive IsAdvancedTextBoxActive: ; 0x020308C4 stmdb sp!, {r3, lr} diff --git a/asm/main_020517F4.s b/asm/main_02051804.s similarity index 98% rename from asm/main_020517F4.s rename to asm/main_02051804.s index fa7174b3..e4f917aa 100644 --- a/asm/main_020517F4.s +++ b/asm/main_02051804.s @@ -1,17 +1,8 @@ .include "asm/macros.inc" - .include "main_020517F4.inc" + .include "main_02051804.inc" .text - arm_func_start GetRankUpEntry -GetRankUpEntry: ; 0x020517F4 - ldr r1, _02051800 ; =RANK_UP_TABLE - add r0, r1, r0, lsl #4 - bx lr - .align 2, 0 -_02051800: .word RANK_UP_TABLE - arm_func_end GetRankUpEntry - arm_func_start sub_02051804 sub_02051804: ; 0x02051804 stmdb sp!, {r4, lr} diff --git a/asm/overlay_29_022E9A44.s b/asm/overlay_29_022E9A6C.s similarity index 96% rename from asm/overlay_29_022E9A44.s rename to asm/overlay_29_022E9A6C.s index 484993b9..307ef31c 100644 --- a/asm/overlay_29_022E9A44.s +++ b/asm/overlay_29_022E9A6C.s @@ -1,22 +1,8 @@ .include "asm/macros.inc" - .include "overlay_29_022E9A44.inc" + .include "overlay_29_022E9A6C.inc" .text - arm_func_start TickStatusTurnCounter -TickStatusTurnCounter: ; 0x022E9A44 - ldrb r1, [r0] - cmp r1, #0x7f - moveq r0, r1 - bxeq lr - cmp r1, #0 - moveq r0, r1 - subne r1, r1, #1 - strneb r1, [r0] - andne r0, r1, #0xff - bx lr - arm_func_end TickStatusTurnCounter - arm_func_start ov29_022E9A6C ov29_022E9A6C: ; 0x022E9A6C ldrh r2, [r0] diff --git a/asm/overlay_29_022E9FE0.s b/asm/overlay_29_022EA008.s similarity index 97% rename from asm/overlay_29_022E9FE0.s rename to asm/overlay_29_022EA008.s index 3745e9f3..c73338d0 100644 --- a/asm/overlay_29_022E9FE0.s +++ b/asm/overlay_29_022EA008.s @@ -1,24 +1,8 @@ .include "asm/macros.inc" - .include "overlay_29_022E9FE0.inc" + .include "overlay_29_022EA008.inc" .text - arm_func_start AdvanceFrame -AdvanceFrame: ; 0x022E9FE0 - stmdb sp!, {r3, lr} - ldr r1, _022EA004 ; =ov29_02353560 - ldrb r1, [r1, #3] - cmp r1, #0 - beq _022E9FFC - bl ov29_022EA2A4 - ldmia sp!, {r3, pc} -_022E9FFC: - bl ov29_022EA324 - ldmia sp!, {r3, pc} - .align 2, 0 -_022EA004: .word ov29_02353560 - arm_func_end AdvanceFrame - arm_func_start ov29_022EA008 ov29_022EA008: ; 0x022EA008 #ifdef JAPAN diff --git a/asm/overlay_29_02305C28.s b/asm/overlay_29_02305C3C.s similarity index 96% rename from asm/overlay_29_02305C28.s rename to asm/overlay_29_02305C3C.s index 823fd7a3..06cc054e 100644 --- a/asm/overlay_29_02305C28.s +++ b/asm/overlay_29_02305C3C.s @@ -1,17 +1,8 @@ .include "asm/macros.inc" - .include "overlay_29_02305C28.inc" + .include "overlay_29_02305C3C.inc" .text - arm_func_start EndNegativeStatusConditionWrapper -EndNegativeStatusConditionWrapper: ; 0x02305C28 - stmdb sp!, {r3, lr} - mov ip, #0 - str ip, [sp] - bl EndNegativeStatusCondition - ldmia sp!, {r3, pc} - arm_func_end EndNegativeStatusConditionWrapper - arm_func_start TransferNegativeStatusCondition TransferNegativeStatusCondition: ; 0x02305C3C #ifdef JAPAN diff --git a/asm/overlay_29_02337EC0.s b/asm/overlay_29_02337EC0.s index fe58b540..524fee28 100644 --- a/asm/overlay_29_02337EC0.s +++ b/asm/overlay_29_02337EC0.s @@ -301,15 +301,3 @@ _02338274: .align 2, 0 _02338284: .word DIRECTIONS_XY arm_func_end ov29_023381C0 - - arm_func_start NearbyAllyIqSkillIsEnabled -NearbyAllyIqSkillIsEnabled: ; 0x02338288 - stmdb sp!, {r3, lr} - mov r2, #0 - bl ov29_023381C0 - cmp r0, #0 - movne r0, #1 - moveq r0, #0 - and r0, r0, #0xff - ldmia sp!, {r3, pc} - arm_func_end NearbyAllyIqSkillIsEnabled diff --git a/asm/overlay_29_0234B350.s b/asm/overlay_29_0234B3A4.s similarity index 65% rename from asm/overlay_29_0234B350.s rename to asm/overlay_29_0234B3A4.s index 009685be..047e1293 100644 --- a/asm/overlay_29_0234B350.s +++ b/asm/overlay_29_0234B3A4.s @@ -1,33 +1,8 @@ .include "asm/macros.inc" - .include "overlay_29_0234B350.inc" + .include "overlay_29_0234B3A4.inc" .text - arm_func_start LogMessageByIdWithPopupCheckUserTarget -LogMessageByIdWithPopupCheckUserTarget: ; 0x0234B350 - stmdb sp!, {r3, r4, r5, r6, r7, lr} - mov r6, r1 - mov r4, #0 - mov r7, r0 - mov r5, r2 - bl ShouldDisplayEntityWrapper - cmp r0, #0 - movne r4, #1 - mov r0, r6 - bl ShouldDisplayEntityWrapper - cmp r0, #0 - movne r4, #1 - cmp r4, #0 - ldmeqia sp!, {r3, r4, r5, r6, r7, pc} - mov r0, r5 - bl StringFromId - mov r1, r0 - mov r0, r7 - mov r2, #1 - bl LogMessage - ldmia sp!, {r3, r4, r5, r6, r7, pc} - arm_func_end LogMessageByIdWithPopupCheckUserTarget - arm_func_start LogMessageWithPopupCheckUserTarget LogMessageWithPopupCheckUserTarget: ; 0x0234B3A4 stmdb sp!, {r3, r4, r5, r6, r7, lr} @@ -100,16 +75,3 @@ LogMessageByIdWithPopupCheckUserUnknown: ; 0x0234B444 bl LogMessage ldmia sp!, {r3, r4, r5, r6, r7, pc} arm_func_end LogMessageByIdWithPopupCheckUserUnknown - - arm_func_start LogMessageByIdWithPopup -LogMessageByIdWithPopup: ; 0x0234B498 - stmdb sp!, {r4, lr} - mov r4, r0 - mov r0, r1 - bl StringFromId - mov r1, r0 - mov r0, r4 - mov r2, #1 - bl LogMessage - ldmia sp!, {r4, pc} - arm_func_end LogMessageByIdWithPopup diff --git a/include/main_02001188.h b/include/main_02001188.h index a8a31104..653baa7a 100644 --- a/include/main_02001188.h +++ b/include/main_02001188.h @@ -1,6 +1,7 @@ #ifndef PMDSKY_MAIN_02001188_H #define PMDSKY_MAIN_02001188_H +void* MemAlloc(u32 len, u32 flags); // Unclear if these structs match, since they haven't been used other than in extern prototypes. Hopefully they do, though. struct mem_block { u32 content_flags; // Bit 0: in_use. Bit 1: object. Bit 2: arena. Bits 3-31: Unused? diff --git a/include/main_020114F8.h b/include/main_020114F8.h index d18a3385..c7113562 100644 --- a/include/main_020114F8.h +++ b/include/main_020114F8.h @@ -1,6 +1,9 @@ #ifndef PMDSKY_MAIN_020114F8_H #define PMDSKY_MAIN_020114F8_H +#include "common.h" + void SwapShopFreeDoublePointer(void** p); +void ApplyGummiBoostsToGroundMonster(struct ground_monster *monster, s16 item_id, int a3, void *a4); #endif diff --git a/include/main_0203088C.h b/include/main_0203088C.h index 3bcb3294..8a3fd671 100644 --- a/include/main_0203088C.h +++ b/include/main_0203088C.h @@ -2,5 +2,6 @@ #define PMDSKY_MAIN_0203088C_H void SetAdvancedTextBoxState5(s32 window_id); +void CloseAdvancedTextBox(s32 window_id); #endif diff --git a/include/main_020517D4.h b/include/main_020517D4.h index 95cb9969..8a2c33d2 100644 --- a/include/main_020517D4.h +++ b/include/main_020517D4.h @@ -4,5 +4,13 @@ // Returns the player's bag capacity for a given point in the game. u32 GetBagCapacity(s32 scenario_balance); u32 GetBagCapacitySpecialEpisode(s32 se_type); +struct unk_020517F4 { + u8 field_0x0[8]; + s32 field_0x8; + s16 field_0xc; + u8 field_0xe[2]; +}; + +struct unk_020517F4* GetRankUpEntry(s32 rank); #endif //PMDSKY_MAIN_020517D4_H diff --git a/include/overlay_29_022E99F0.h b/include/overlay_29_022E99F0.h index 2589a19a..c7c5c60f 100644 --- a/include/overlay_29_022E99F0.h +++ b/include/overlay_29_022E99F0.h @@ -6,5 +6,6 @@ struct position* FindClosestUnoccupiedTileWithin2(struct position* out, struct position* origin, bool8 a); struct position* FindFarthestUnoccupiedTileWithin2(struct position* out, struct position* origin, bool8 a); struct position* FindUnoccupiedTileWithin3(struct position* out, struct position* origin, bool8 a); +u8 TickStatusTurnCounter(u8 *counter); #endif diff --git a/include/overlay_29_022E9FC0.h b/include/overlay_29_022E9FC0.h index 57171a5f..86d4fb99 100644 --- a/include/overlay_29_022E9FC0.h +++ b/include/overlay_29_022E9FC0.h @@ -3,5 +3,6 @@ u8 ov29_022E9FC0(void); void ov29_022E9FD0(u8 value); +void AdvanceFrame(u32 param_1); #endif diff --git a/include/overlay_29_02305C04.h b/include/overlay_29_02305C04.h index ba403710..0d0b4f53 100644 --- a/include/overlay_29_02305C04.h +++ b/include/overlay_29_02305C04.h @@ -5,5 +5,6 @@ // Checks if an entity pointer points to a valid entity (not entity type 0, which represents no entity). bool8 EntityIsValid__02305C04(struct entity *entity); +void EndNegativeStatusConditionWrapper(struct entity *user, struct entity *target, bool8 displayMessage, bool8 fromMove); #endif //PMDSKY_OVERLAY_29_02305C04_H diff --git a/include/overlay_29_02338350.h b/include/overlay_29_02338350.h index 0ce94e2c..c99f46c6 100644 --- a/include/overlay_29_02338350.h +++ b/include/overlay_29_02338350.h @@ -3,6 +3,7 @@ #include "dungeon_mode.h" +bool8 NearbyAllyIqSkillIsEnabled(struct entity *entity, enum iq_skill_id iq_skill); struct entity* FindAdjacentEnemy(struct entity *monster); bool8 IsAdjacentToEnemyIgnoreTreatment(struct entity *monster); diff --git a/include/overlay_29_0234B340.h b/include/overlay_29_0234B340.h index 2f1e8df5..44db9db5 100644 --- a/include/overlay_29_0234B340.h +++ b/include/overlay_29_0234B340.h @@ -6,5 +6,6 @@ #include "move.h" void LogMessageQuiet(struct entity *user, const char *message); +void LogMessageByIdWithPopupCheckUserTarget(struct entity *user, struct entity *target, u32 message_id); #endif diff --git a/include/overlay_29_0234B4BC.h b/include/overlay_29_0234B4BC.h index ff5c76f7..f5e0c2e4 100644 --- a/include/overlay_29_0234B4BC.h +++ b/include/overlay_29_0234B4BC.h @@ -5,6 +5,7 @@ #include "item.h" #include "move.h" +void LogMessageByIdWithPopup(struct entity *user, s32 message_id); void LogMessageWithPopup(struct entity *user, const char *message); #endif diff --git a/main.lsf b/main.lsf index 2da6b02e..f036ca29 100644 --- a/main.lsf +++ b/main.lsf @@ -95,7 +95,7 @@ Static main Object src/exclusive_item.o Object asm/main_02010FC4.o Object src/main_020114F8.o - Object asm/main_02011528.o + Object asm/main_02011554.o Object src/main_02011830.o Object asm/main_02011850.o Object src/main_02011DF0.o @@ -188,7 +188,7 @@ Static main Object src/main_020307A4.o Object src/main_0203083C.o Object src/main_0203088C.o - Object asm/main_020308A0.o + Object asm/main_020308C4.o Object src/main_02030A18.o Object src/main_02030A40.o Object asm/main_02030A90.o @@ -282,7 +282,7 @@ Static main Object src/iq_skills.o Object asm/main_rodata_020A20B1.o Object src/main_020517D4.o - Object asm/main_020517F4.o + Object asm/main_02051804.o Object src/main_02051FF0.o Object asm/main_02052060.o Object src/main_020526EC.o @@ -841,9 +841,9 @@ Overlay OVY_29 Object src/dg_uty.o Object asm/overlay_29_022E9628.o Object src/overlay_29_022E99F0.o - Object asm/overlay_29_022E9A44.o + Object asm/overlay_29_022E9A6C.o Object src/overlay_29_022E9FC0.o - Object asm/overlay_29_022E9FE0.o + Object asm/overlay_29_022EA008.o Object src/overlay_29_022EA968.o Object src/overlay_29_022EA9CC.o Object src/dg_random.o @@ -968,7 +968,7 @@ Overlay OVY_29 Object src/overlay_29_0230558C.o Object asm/overlay_29_023055B0.o Object src/overlay_29_02305C04.o - Object asm/overlay_29_02305C28.o + Object asm/overlay_29_02305C3C.o Object src/overlay_29_023061A8.o Object asm/overlay_29_02306258.o Object src/overlay_29_02306728.o @@ -1282,7 +1282,7 @@ Overlay OVY_29 Object src/overlay_29_0234B104.o Object asm/overlay_29_0234B130.o Object src/overlay_29_0234B340.o - Object asm/overlay_29_0234B350.o + Object asm/overlay_29_0234B3A4.o Object src/overlay_29_0234B4BC.o Object asm/overlay_29_0234B4CC.o Object src/overlay_29_0234BA54.o diff --git a/src/directory_file.c b/src/directory_file.c index 9088da44..c5cd0651 100644 --- a/src/directory_file.c +++ b/src/directory_file.c @@ -4,8 +4,8 @@ extern const struct unk_02094C18 _02094C18; #include "file_rom.h" #include "debug.h" +#include "main_02001188.h" -extern void* MemAlloc(u32 len, u32 flags); extern char STRING_FILE_DIRECTORY_INIT; diff --git a/src/directory_file_mngr.c b/src/directory_file_mngr.c index 0265e9f9..95f59ef1 100644 --- a/src/directory_file_mngr.c +++ b/src/directory_file_mngr.c @@ -1,7 +1,7 @@ #include "directory_file_mngr.h" #include "directory_file.h" +#include "main_02001188.h" -extern void* MemAlloc(u32 len, u32 flags); extern void MemZero(void* ptr, u32 len); extern struct directory *DIRECTORY_FILES_EXTRACTED; diff --git a/src/dungeon_projectile_throw.c b/src/dungeon_projectile_throw.c index 058b1cea..5a2d5544 100644 --- a/src/dungeon_projectile_throw.c +++ b/src/dungeon_projectile_throw.c @@ -12,6 +12,8 @@ #include "moves_1.h" #include "overlay_29_02344AF8.h" #include "dungeon_util_2.h" +#include "overlay_29_022E9FC0.h" +#include "overlay_29_0234B340.h" #ifdef JAPAN #define CURVED_PROJECTILE_LOG_MESSAGE_1 0x920 @@ -30,11 +32,9 @@ extern void ov29_0234B4CC(bool8 val); extern s32 SinAbs4096(s32 x); extern bool8 DisplayThrownItemShadow(s32 x, s32 y, u8 index); extern bool8 DisplayItem(struct entity *item, bool8 hallucinate, u8 on_floor, u8 dir, u8 priority); -extern void AdvanceFrame(u32 param_1); extern bool8 TwoTurnMoveForcedMiss(struct entity *target, struct move *move); extern bool8 DoesProjectileHitTarget(struct entity *user, struct entity *target); extern void ChangeMonsterAnimationToHurt(struct entity *monster, u32 direction); -extern void LogMessageByIdWithPopupCheckUserTarget(struct entity *user, struct entity *target, u32 message_id); extern bool8 TryEndPetrifiedOrSleepStatus(struct entity *user, struct entity *target); extern bool8 SpawnDroppedItem(struct entity *entity, struct entity *item_entity, struct item *item, bool8 param_4, struct position *dir_xy, u32 param_6); diff --git a/src/ground_bg.c b/src/ground_bg.c index 1b2d3841..47ea280b 100644 --- a/src/ground_bg.c +++ b/src/ground_bg.c @@ -7,7 +7,6 @@ #define VRAM 0x6000000 extern void FileClose(struct file_stream* file); -extern void* MemAlloc(u32 len, u32 flags); extern s32 sprintf(u8* str, const u8* format, ...); extern void LoadFileFromRom(struct iovec* iov, const char* filepath, u32 flags); diff --git a/src/main_02001188.c b/src/main_02001188.c index 2ecc398e..12dbee90 100644 --- a/src/main_02001188.c +++ b/src/main_02001188.c @@ -1,5 +1,12 @@ #include "main_02001188.h" +extern void *MemLocateSet(struct mem_arena *arena, u32 len, u32 flags); + +void* MemAlloc(u32 len, u32 flags) +{ + return MemLocateSet(0, len, flags); +} + extern void MemLocateUnset(struct mem_arena *arena, void *ptr); void MemFree(void * ptr) diff --git a/src/main_020114F8.c b/src/main_020114F8.c index 73ae4b14..e9f3945e 100644 --- a/src/main_020114F8.c +++ b/src/main_020114F8.c @@ -1,5 +1,8 @@ #include "main_020114F8.h" #include "main_02001188.h" +#include "common.h" + +extern void ApplyGummiBoostsGroundMode(s16 *monster_id, u16 *iq, u8 *offensive_stats, u8 *defensive_stats, s16 item_id, int a6, void *a7); void SwapShopFreeDoublePointer(void** p) { @@ -10,3 +13,9 @@ void SwapShopFreeDoublePointer(void** p) MemFree(*p); *p = NULL; } + +void ApplyGummiBoostsToGroundMonster(struct ground_monster *monster, s16 item_id, int a3, void *a4) +{ + ApplyGummiBoostsGroundMode(&monster->id, &monster->iq, monster->offensive_stats, + monster->defensive_stats, item_id, a3, a4); +} diff --git a/src/main_0203088C.c b/src/main_0203088C.c index 19e5b168..84591122 100644 --- a/src/main_0203088C.c +++ b/src/main_0203088C.c @@ -8,3 +8,12 @@ void SetAdvancedTextBoxState5(s32 window_id) w->field_0x1BC = 5; } + +void CloseAdvancedTextBox(s32 window_id) +{ + void *contents; + + contents = GetWindowContents(window_id); + DeleteWindow(window_id); + MemFree(contents); +} diff --git a/src/main_0203D538.c b/src/main_0203D538.c index 1d08e6ca..f51fd192 100644 --- a/src/main_0203D538.c +++ b/src/main_0203D538.c @@ -17,13 +17,7 @@ #include "main_0203755C.h" #include "progression.h" #include "script_variable.h" - -struct unk_020517F4 { - u8 field_0x0[8]; - s32 field_0x8; - s16 field_0xc; - u8 field_0xe[2]; -}; +#include "main_020517D4.h" struct unk_020AFE74 { s32 field_0x0; @@ -98,7 +92,6 @@ extern void sub_02045FD0(struct item *out); extern bool8 AddItemToStorage(struct item *item); extern void InitUnkStorageStruct0x410(struct item *, u8); extern s32 GetRank(void); -extern struct unk_020517F4 *GetRankUpEntry(s32 rank); extern void sub_0203F00C(void); extern void MissionRewardCloseAllBoxes(void); extern struct ground_monster *sub_02055D4C(struct ground_monster *mon); diff --git a/src/main_02042B84.c b/src/main_02042B84.c index 1aca27a0..94eb2feb 100644 --- a/src/main_02042B84.c +++ b/src/main_02042B84.c @@ -2,7 +2,6 @@ #include "main_02042AF8.h" #include "main_02001188.h" -void *MemAlloc(u32 size, u32 nmemb); s32 IsBagItemIndexSelected(s32 idx) { diff --git a/src/main_020517D4.c b/src/main_020517D4.c index 15a8c621..e43825c1 100644 --- a/src/main_020517D4.c +++ b/src/main_020517D4.c @@ -1,6 +1,8 @@ #include "main_020517D4.h" #include "enums.h" +extern struct unk_020517F4 RANK_UP_TABLE[]; + // Array of 4-byte integers containing the bag capacity for each bag level. const u32 BAG_CAPACITY_TABLE[8] = { 16, 24, 32, 40, 40, 40, 48, 48 }; const u32 BAG_CAPACITY_TABLE_SPECIAL_EPISODES[NUM_SPECIAL_EPISODES] = @@ -21,3 +23,8 @@ u32 GetBagCapacitySpecialEpisode(s32 se_type) { return BAG_CAPACITY_TABLE_SPECIAL_EPISODES[se_type]; } + +struct unk_020517F4* GetRankUpEntry(s32 rank) +{ + return &RANK_UP_TABLE[rank]; +} diff --git a/src/main_02051FF0.c b/src/main_02051FF0.c index 6b75ede9..68db72e8 100644 --- a/src/main_02051FF0.c +++ b/src/main_02051FF0.c @@ -1,9 +1,9 @@ #include "main_02051FF0.h" #include "main_02008BD4.h" +#include "main_02001188.h" extern void LoadFileFromRom(struct iovec *handle, u32 fileId, s32 param2); extern s32 GetAtSize(void *data); -extern void *MemAlloc(u32 size, u32 heapId); extern void DecompressAtNormalVeneer(void *dest, u32 size, void *src); s32 sub_02051FF0(u32 fileId, void **outPtr, s32 param2) diff --git a/src/main_0205D11C.c b/src/main_0205D11C.c index a5ce1bb0..2b8a8bfe 100644 --- a/src/main_0205D11C.c +++ b/src/main_0205D11C.c @@ -28,7 +28,6 @@ extern const char _020A3B18[]; extern s32 RandIntSafe(s32 n); extern void ClearMissionData(struct mission *mission); -extern void *MemAlloc(u32 len, u32 flags); extern struct mission_deliver_list MISSION_DELIVER_LIST_PTR; extern s32 CanDungeonBeUsedForMission(enum dungeon_id); extern s32 CountAndPopulateValidMissionTableMonsters(s16 **out, struct unk_0205DFAC *spec); diff --git a/src/move_orb_effects.c b/src/move_orb_effects.c index 282bf3ce..4ff10e51 100644 --- a/src/move_orb_effects.c +++ b/src/move_orb_effects.c @@ -11,6 +11,7 @@ #include "overlay_29_02344AF8.h" #include "dungeon_util_2.h" #include "overlay_29_022E3F20.h" +#include "overlay_29_0234B340.h" extern u8* AllocateTemp1024ByteBufferFromPool(void); extern void CopyStringFromId(u8* buf, u32 string_id); @@ -26,7 +27,6 @@ extern void PlayDefensiveStatMultiplierDownEffect(struct entity *entity, struct extern void PlayDefensiveStatMultiplierUpEffect(struct entity *entity, struct StatIndex stat_index); extern void PlayHitChanceUpEffect(struct entity *entity, struct StatIndex stat_index); extern void PlayHitChanceDownEffect(struct entity *entity, struct StatIndex stat_index); -extern void LogMessageByIdWithPopupCheckUserTarget(struct entity *user, struct entity *target, u32 message_id); extern void ov29_022E4338(struct entity *); extern void PlayExclamationPointEffect__022E5D4C(struct entity *entity); extern void PlayParalysisEffect(struct entity *entity); diff --git a/src/overlay_10_022BFD58.c b/src/overlay_10_022BFD58.c index 1e7aaf49..86de60d7 100644 --- a/src/overlay_10_022BFD58.c +++ b/src/overlay_10_022BFD58.c @@ -1,8 +1,8 @@ #include "overlay_10_022BFD58.h" +#include "main_02001188.h" extern struct unk_022DC1C4 *ov10_022DC1C4; -extern void *MemAlloc(u32 size, u32 flags); extern void MemZero(void *p, s32 n); diff --git a/src/overlay_11_02307334.c b/src/overlay_11_02307334.c index d9e1e7e5..8a6a036a 100644 --- a/src/overlay_11_02307334.c +++ b/src/overlay_11_02307334.c @@ -18,6 +18,8 @@ #include "main_02058E68.h" #include "overlay_10_022BCC60.h" #include "overlay_31_02382820.h" +#include "main_020114F8.h" +#include "main_0203088C.h" struct unk_02309DAC { s32 field_0x0; @@ -100,9 +102,7 @@ extern void InitPreprocessorArgs(struct preprocessor_args *); extern s32 IsScrollBoxActive(s8); extern void ShowDialogueBox(s8); extern void ShowStringIdInDialogueBox(s8, s32, s32, void *); extern void ov11_022DC504(void); extern u8 *strcpy(u8 *dest, const u8 *src); -extern void ApplyGummiBoostsToGroundMonster(struct ground_monster *, s16, int, void *); extern void ApplyGummiBoostsToTeamMember(struct team_member *, s16, int, void *); -extern void CloseAdvancedTextBox(s32 window_id); extern s8 CreateInventoryMenuOuter(s32, s32, s32, void *, void *, void *, u8); extern bool8 IsBagNotEmpty(void); extern u8 PopInventoryMenuField0x1A3(s32 window_id); diff --git a/src/overlay_13_EntryOverlay13.c b/src/overlay_13_EntryOverlay13.c index 9ceb550a..5b4cba94 100644 --- a/src/overlay_13_EntryOverlay13.c +++ b/src/overlay_13_EntryOverlay13.c @@ -2,7 +2,6 @@ #include "overlay_13_0238BDA8.h" #include "main_02001188.h" -extern void* MemAlloc(u32 len, u32 flags); void sub_0201F2E4(void); void InitMenu(const u8 *); extern void ReturnScriptMenuResult(u32); diff --git a/src/overlay_15_0238A140.c b/src/overlay_15_0238A140.c index 87cfbebd..ebf8afb8 100644 --- a/src/overlay_15_0238A140.c +++ b/src/overlay_15_0238A140.c @@ -1,8 +1,8 @@ #include "overlay_15_0238A140.h" +#include "main_02001188.h" extern unkBankStruct* DUSKULL_BANK_STRUCT_PTR; -extern void* MemAlloc(u32 len, u32 flags); extern void InitPreprocessorArgs(preprocessor_args*); extern u32 CreateDialogueBox(u32); extern u32 CreatePortraitBox(u32, u32, u32); diff --git a/src/overlay_24_end.c b/src/overlay_24_end.c index 4e8143f1..bd792f2c 100644 --- a/src/overlay_24_end.c +++ b/src/overlay_24_end.c @@ -17,7 +17,6 @@ void GetNameRaw(unsigned char *, s32); void GetNameWithGender(unsigned char*, s32, char color_id); s8 GetUnkGameState0x13a6(); extern void InitPreprocessorArgs(void* args); -void* MemAlloc(s32, s32); s16 ReturnEggExclusiveItem(s32); void SetUnkGameState0x13a6(s32); void StrcpyName(const unsigned char*, const unsigned char*); diff --git a/src/overlay_25_init.c b/src/overlay_25_init.c index db610649..8538eec2 100644 --- a/src/overlay_25_init.c +++ b/src/overlay_25_init.c @@ -1,6 +1,7 @@ #include "overlay_25.h" #include "main_0200C4FC.h" #include "item.h" +#include "main_02001188.h" extern void CloseDialogueBox(s8); @@ -50,7 +51,6 @@ extern void ShowPortraitInPortraitBox(s8, void*); extern void SwapShopInventoryManager(s32, s32); extern void ov11_022DC504(); extern void ov11_0230C910(); -extern void* MemAlloc(s32, s32); extern void MemFree(void *ptr); extern BOOL IsScriptMenuReturnDisabled(); extern void ReturnScriptMenuResult(s32); diff --git a/src/overlay_29_022DEAB0.c b/src/overlay_29_022DEAB0.c index a9d55ed4..99373de4 100644 --- a/src/overlay_29_022DEAB0.c +++ b/src/overlay_29_022DEAB0.c @@ -1,9 +1,9 @@ #include "overlay_29_022DEAB0.h" #include "dungeon.h" +#include "main_02001188.h" void MemFree(void* ptr); void MemZero(void* ptr, u32 len); -void* MemAlloc(u32 len, u32 flags); void ov29_0234C654(s32); void sub_020091B0(s32, s32); void sub_02009194(s32, s32); diff --git a/src/overlay_29_022E99F0.c b/src/overlay_29_022E99F0.c index 56fdcd42..fd8d57ab 100644 --- a/src/overlay_29_022E99F0.c +++ b/src/overlay_29_022E99F0.c @@ -23,3 +23,15 @@ struct position* FindUnoccupiedTileWithin3(struct position* out, struct position { return FindNearbyUnoccupiedTile(out, origin, DISPLACEMENTS_WITHIN_3, 0x31, a); } + +u8 TickStatusTurnCounter(u8 *counter) +{ + u8 turns = *counter; + + if (turns == 0x7F) + return turns; + if (turns == 0) + return turns; + *counter = turns - 1; + return *counter; +} diff --git a/src/overlay_29_022E9FC0.c b/src/overlay_29_022E9FC0.c index 4538368b..5f5f58d1 100644 --- a/src/overlay_29_022E9FC0.c +++ b/src/overlay_29_022E9FC0.c @@ -1,5 +1,8 @@ #include "overlay_29_022E9FC0.h" +extern void ov29_022EA2A4(u32 param_1); +extern void ov29_022EA324(u32 param_1); + struct unk_02353560 { u8 field_0x0; u8 field_0x1; @@ -19,3 +22,13 @@ void ov29_022E9FD0(u8 value) { ov29_02353560.field_0x3 = value; } + +void AdvanceFrame(u32 param_1) +{ + if (ov29_02353560.field_0x3) { + ov29_022EA2A4(param_1); + } + else { + ov29_022EA324(param_1); + } +} diff --git a/src/overlay_29_022F0EDC.c b/src/overlay_29_022F0EDC.c index 74dec6e3..f896345b 100644 --- a/src/overlay_29_022F0EDC.c +++ b/src/overlay_29_022F0EDC.c @@ -19,6 +19,7 @@ #include "position_util.h" #include "dungeon_util_2.h" #include "overlay_29_022EC7E8.h" +#include "overlay_29_022E9FC0.h" #ifdef JAPAN #define SET_LEADER_ACTION_DATA_OFFSET -0x2C1 @@ -47,7 +48,6 @@ extern struct unk_0237C9A4 ov29_0237C9A4; extern u16 DUNGEON_BUTTON_INPUT[8]; extern u16 ov29_0237C6A4; -extern void AdvanceFrame(u32); extern bool8 CanSeeTarget(struct entity *user, struct entity *target); extern bool8 IsBlinded(struct entity *entity, bool8 check_held_item); extern void MemZero(u8 *ptr, s32 len); diff --git a/src/overlay_29_02305C04.c b/src/overlay_29_02305C04.c index 5318d7e9..f69acedb 100644 --- a/src/overlay_29_02305C04.c +++ b/src/overlay_29_02305C04.c @@ -1,6 +1,8 @@ #include "overlay_29_02305C04.h" #include "dungeon_util_static.h" +extern s32 EndNegativeStatusCondition(struct entity *user, struct entity *target, bool8 a, bool8 b, bool8 c); + bool8 EntityIsValid__02305C04(struct entity *entity) { if (entity == NULL) @@ -8,3 +10,8 @@ bool8 EntityIsValid__02305C04(struct entity *entity) return GetEntityType(entity) != ENTITY_NOTHING; } + +void EndNegativeStatusConditionWrapper(struct entity *user, struct entity *target, bool8 displayMessage, bool8 fromMove) +{ + EndNegativeStatusCondition(user, target, displayMessage, fromMove, FALSE); +} diff --git a/src/overlay_29_023061A8.c b/src/overlay_29_023061A8.c index a862fef3..4f9a0a76 100644 --- a/src/overlay_29_023061A8.c +++ b/src/overlay_29_023061A8.c @@ -3,6 +3,7 @@ #include "dungeon_util_2.h" #include "overlay_29_022E3F20.h" #include "dungeon_util_static.h" +#include "overlay_29_0234B340.h" #ifdef JAPAN #define JPN_MSG_OFFSET -0x2C0 @@ -10,7 +11,6 @@ #define JPN_MSG_OFFSET 0 #endif -extern void LogMessageByIdWithPopupCheckUserTarget(struct entity *user, struct entity *target, u32 message_id); void EndBurnClassStatus(struct entity *user, struct entity *target) { diff --git a/src/overlay_29_02308FBC.c b/src/overlay_29_02308FBC.c index 07b0f9da..9de9eb2f 100644 --- a/src/overlay_29_02308FBC.c +++ b/src/overlay_29_02308FBC.c @@ -47,6 +47,10 @@ #include "overlay_29_02345A3C.h" #include "overlay_29_02306728.h" #include "overlay_29_02336F4C.h" +#include "main_0205283C.h" +#include "overlay_29_022E9FC0.h" +#include "overlay_29_0234B340.h" +#include "overlay_29_0234B4BC.h" struct unk_023535DC { u8 field_0x0; @@ -95,7 +99,6 @@ extern s16 ov10_022C45C0; extern s16 ov10_022C4638; extern s16 ov10_022C467C; extern void AddExpSpecial(struct entity* attacker, struct entity* defender, s32 base_exp); -extern void AdvanceFrame(u32); extern bool8 AftermathCheck(struct entity *attacker, struct entity *defender, s32 damage_source); extern void ChangeMonsterAnimation(struct entity *entity, s32 animation_id, s32 direction); extern void ChangeMonsterAnimationToIdle(struct entity* monster, enum direction_id direction); @@ -106,13 +109,10 @@ extern bool8 ExclusiveItemEffectIsActiveWithLogging(struct entity* user, struct extern void FillRecruitInfo(void *recruit_info, struct entity *monster); extern void FreeOtherWrappedMonsters(u32 unique_id); extern struct team_member* GetActiveTeamMember(s32 roster_idx); -extern s32 GetExp(enum monster_id monster_id, s32 level); extern s32 GetIdleAnimationId(struct entity *entity); extern void HandleFaint(struct entity *fainted_entity, s32 damage_source, struct entity *killer); extern bool8 IsMonsterIdInNormalRangeVeneer(enum monster_id monster_id); -extern void LogMessageByIdWithPopup(struct entity* user, s32 message_id); extern void LogMessageByIdWithPopupCheckUser(struct entity *user, u32 message_id); -extern void LogMessageByIdWithPopupCheckUserTarget(struct entity *user, struct entity *target, u32 message_id); extern void MoveMonsterToPos(struct entity* entity, s32 x_pos, s32 y_pos, bool8 reset_prev_pos_fields); extern enum music_id MusicTableIdxToMusicId(s32 music_table_idx); extern s32 PlayEffectAnimationEntity(struct entity *entity, s32 id, s32 a, u8 b, s32 c, s32 d, s32 e, s32 f); diff --git a/src/overlay_29_0230BBAC.c b/src/overlay_29_0230BBAC.c index fb6d1431..c0f0b885 100644 --- a/src/overlay_29_0230BBAC.c +++ b/src/overlay_29_0230BBAC.c @@ -25,13 +25,14 @@ #include "type_effectiveness.h" #include "weather.h" #include "dungeon_util_2.h" +#include "overlay_29_02338350.h" +#include "overlay_29_0234B340.h" extern struct dungeon *DUNGEON_PTR; extern u8 GetMonsterGenderVeneer(s16 monster_id); extern u8 ExclusiveItemOffenseBoost(struct entity *entity, s32 idx); extern u8 ExclusiveItemDefenseBoost(struct entity *entity, s32 idx); extern int MoveIsNotPhysical(enum move_id move_id); -extern bool8 NearbyAllyIqSkillIsEnabled(struct entity *entity, enum iq_skill_id iq_skill); extern s32 FixedPoint64ToInt(struct fixed_point_64 *x); extern void AddFixedPoint64(struct fixed_point_64 *out, struct fixed_point_64 *a, struct fixed_point_64 *b); extern void ClampedLn(struct fixed_point_64 *out, s32 x); @@ -45,7 +46,6 @@ extern void DivideFixedPoint64(struct fixed_point_64 *out, struct fixed_point_64 extern void ResetDamageCalcDiagnostics(void); extern bool8 OtherMonsterAbilityIsActive(struct entity *entity, enum ability_id ability_id); extern void MultiplyFixedPoint64(struct fixed_point_64 *out, const struct fixed_point_64 *a, const struct fixed_point_64 *b); -extern void LogMessageByIdWithPopupCheckUserTarget(struct entity *user, struct entity *target, u32 message_id); extern bool8 UpdateStateFlags(struct monster *info, s32 flag, bool8 value); extern void ResetDamageData(struct unk_02308FE0 *damage_data); extern bool8 ExclusiveItemEffectIsActiveWithLogging(struct entity *user, struct entity *target, bool8 should_log, s32 message_id, enum exclusive_item_effect_id effect_id); diff --git a/src/overlay_29_02311010.c b/src/overlay_29_02311010.c index 85c39318..a79e0d18 100644 --- a/src/overlay_29_02311010.c +++ b/src/overlay_29_02311010.c @@ -23,6 +23,8 @@ #include "dungeon_util_2.h" #include "overlay_29_022EC7E8.h" #include "overlay_29_023061A8.h" +#include "overlay_29_022E99F0.h" +#include "overlay_29_02305C04.h" #ifdef JAPAN #define MESSAGE_DE6 0xB26 @@ -58,12 +60,10 @@ extern void LogMessageByIdWithPopupCheckUser(struct entity *user, u32 message_id extern void TryIncreaseHp(struct entity *user, struct entity *target, s32 hp, s32 a, bool8 b); extern void TryWarp(struct entity *user, struct entity *target, s32 a, s32 b); extern void MultiplyFixedPoint64(struct fixed_point_64 *out, const struct fixed_point_64 *a, const struct fixed_point_64 *b); -extern void EndNegativeStatusConditionWrapper(struct entity *user, struct entity *target, bool8 displayMessage, bool8 fromMove); extern void ov29_022EA370(s32 a, s32 b); extern s32 ov29_022F2FE4(); extern void WaitUntilAlertBoxTextIsLoadedWrapper(void); -extern u8 TickStatusTurnCounter(u8 *counter); extern void EnsureCanStandCurrentTile(struct entity *entity); extern void ov29_022E543C(struct entity *entity); extern void ov29_022E53F0(struct entity *entity); diff --git a/src/overlay_29_0231CBC8.c b/src/overlay_29_0231CBC8.c index 118439f9..bf627602 100644 --- a/src/overlay_29_0231CBC8.c +++ b/src/overlay_29_0231CBC8.c @@ -12,6 +12,8 @@ #include "overlay_29_0234BA54.h" #include "dungeon_util_2.h" #include "overlay_29_02345A3C.h" +#include "overlay_29_02305C04.h" +#include "overlay_29_0234B340.h" #ifdef JAPAN #define MESSAGE_BE6 0x925 @@ -36,9 +38,7 @@ extern void ov29_022FB920(bool8 a); #endif -extern void LogMessageByIdWithPopupCheckUserTarget(struct entity *user, struct entity *target, u32 message_id); extern void TryIncreaseHp(struct entity *user, struct entity *target, s32 hp, s32 a, bool8 b); -extern void EndNegativeStatusConditionWrapper(struct entity *user, struct entity *target, bool8 displayMessage, bool8 fromMove); extern void TryWarp(struct entity *user, struct entity *target, s32 a, s32 b); extern void BoostIQ(struct entity *entity, s16 iq, bool8 a); extern void UpdateShopkeeperModeAfterAttack(struct entity *attacker, struct entity *defender); diff --git a/src/overlay_29_02326188.c b/src/overlay_29_02326188.c index 6b9fa417..e52805d3 100644 --- a/src/overlay_29_02326188.c +++ b/src/overlay_29_02326188.c @@ -3,6 +3,7 @@ #include "item.h" #include "move.h" #include "move_orb_effects.h" +#include "overlay_29_02305C04.h" extern const s16 BUBBLE_LOWER_SPEED_CHANCE; @@ -10,7 +11,6 @@ extern s32 DealDamage(struct entity *attacker, struct entity *defender, struct m extern bool8 DungeonRandOutcomeUserTargetInteraction(struct entity *user, struct entity *target, s16 chance); -extern void EndNegativeStatusConditionWrapper(struct entity *user, struct entity *target, bool8 displayMessage, bool8 fromMove); bool8 DoMoveHealStatus(struct entity* attacker, struct entity* defender, struct move* move, enum item_id item_id) { diff --git a/src/overlay_29_02329664.c b/src/overlay_29_02329664.c index df828ac9..49379c1e 100644 --- a/src/overlay_29_02329664.c +++ b/src/overlay_29_02329664.c @@ -1,5 +1,6 @@ #include "overlay_29_02329664.h" #include "move_orb_effects.h" +#include "overlay_29_0234B340.h" #ifdef JAPAN #define HELPING_HAND_LOG_MESSAGE 0xC1C @@ -8,7 +9,6 @@ #endif -extern void LogMessageByIdWithPopupCheckUserTarget(struct entity *user, struct entity *target, u32 message_id); extern const struct StatIndex ATK_STAT_IDX; diff --git a/src/overlay_29_0232A480.c b/src/overlay_29_0232A480.c index e6eebe9a..5e575c7f 100644 --- a/src/overlay_29_0232A480.c +++ b/src/overlay_29_0232A480.c @@ -1,5 +1,6 @@ #include "overlay_29_0232A480.h" #include "dungeon_util_static.h" +#include "overlay_29_0234B340.h" #ifdef JAPAN #define SWALLOW_LOG_MESSAGE 0xC26 @@ -8,7 +9,6 @@ #endif -extern void LogMessageByIdWithPopupCheckUserTarget(struct entity *user, struct entity *target, u32 message_id); extern const s32 ov10_022C49D4[]; diff --git a/src/overlay_29_0232CE40.c b/src/overlay_29_0232CE40.c index 32e3545b..34cda62b 100644 --- a/src/overlay_29_0232CE40.c +++ b/src/overlay_29_0232CE40.c @@ -1,4 +1,5 @@ #include "overlay_29_0232CE40.h" +#include "overlay_29_0234B340.h" #ifdef JAPAN #define REVIVER_LOG_MESSAGE 0xC4B @@ -7,7 +8,6 @@ #endif -extern void LogMessageByIdWithPopupCheckUserTarget(struct entity *user, struct entity *target, u32 message_id); extern s16 ov10_022C456C; diff --git a/src/overlay_29_0232D368.c b/src/overlay_29_0232D368.c index 938f5173..bb73c735 100644 --- a/src/overlay_29_0232D368.c +++ b/src/overlay_29_0232D368.c @@ -1,5 +1,6 @@ #include "overlay_29_0232D368.h" #include "dungeon_util_2.h" +#include "overlay_29_0234B340.h" #ifdef JAPAN #define GUARD_SWAP_LOG_MESSAGE 0x2495 @@ -7,7 +8,6 @@ #define GUARD_SWAP_LOG_MESSAGE 0xF2E #endif -extern void LogMessageByIdWithPopupCheckUserTarget(struct entity *user, struct entity *target, u32 message_id); extern void SwapDefensiveStages(struct entity *attacker, struct entity *defender, s32 log_message); extern void SwapDefensiveMultipliers(struct entity *attacker, struct entity *defender, s32 log_message); extern void TryInflictLuckyChantStatus(struct entity *user, struct entity *target); diff --git a/src/overlay_29_02338350.c b/src/overlay_29_02338350.c index cfe26628..4a957e6d 100644 --- a/src/overlay_29_02338350.c +++ b/src/overlay_29_02338350.c @@ -3,6 +3,13 @@ #include "dungeon_util.h" #include "dungeon_util_static.h" +extern struct entity *ov29_023381C0(struct entity *entity, enum iq_skill_id iq_skill, bool8 param_3); + +bool8 NearbyAllyIqSkillIsEnabled(struct entity *entity, enum iq_skill_id iq_skill) +{ + return ov29_023381C0(entity, iq_skill, FALSE) != NULL; +} + struct entity* FindAdjacentEnemy(struct entity *monster) { s16 i; diff --git a/src/overlay_29_0234B340.c b/src/overlay_29_0234B340.c index a2245de4..d6d433d7 100644 --- a/src/overlay_29_0234B340.c +++ b/src/overlay_29_0234B340.c @@ -1,4 +1,6 @@ #include "overlay_29_0234B340.h" +#include "main_0202593C.h" +#include "overlay_29_022E272C.h" extern void LogMessage(struct entity *user, const char *message, bool8 show_popup); @@ -6,3 +8,16 @@ void LogMessageQuiet(struct entity *user, const char *message) { LogMessage(user, message, FALSE); } + +void LogMessageByIdWithPopupCheckUserTarget(struct entity *user, struct entity *target, u32 message_id) +{ + bool8 display = FALSE; + + if (ShouldDisplayEntityWrapper(user)) + display = TRUE; + if (ShouldDisplayEntityWrapper(target)) + display = TRUE; + + if (display) + LogMessage(user, (char *)StringFromId(message_id), TRUE); +} diff --git a/src/overlay_29_0234B4BC.c b/src/overlay_29_0234B4BC.c index 7794fd8b..ad2eaf4c 100644 --- a/src/overlay_29_0234B4BC.c +++ b/src/overlay_29_0234B4BC.c @@ -1,7 +1,13 @@ #include "overlay_29_0234B4BC.h" +#include "main_0202593C.h" extern void LogMessage(struct entity *user, const char *message, bool8 show_popup); +void LogMessageByIdWithPopup(struct entity *user, s32 message_id) +{ + LogMessage(user, (char *)StringFromId(message_id), TRUE); +} + void LogMessageWithPopup(struct entity *user, const char *message) { LogMessage(user, message, TRUE); diff --git a/src/overlay_29_0234BA54.c b/src/overlay_29_0234BA54.c index e8b277d5..a6d9423a 100644 --- a/src/overlay_29_0234BA54.c +++ b/src/overlay_29_0234BA54.c @@ -1,5 +1,6 @@ #include "overlay_29_0234BA54.h" #include "overlay_29_0234B024.h" +#include "overlay_29_022E9FC0.h" extern struct message_log_info MESSAGE_LOG_INFO; extern u16 DUNGEON_BUTTON_INPUT[8]; @@ -18,7 +19,6 @@ extern void sub_02047FFC(s32 a); extern void InitPortraitParams(portrait_params *portrait); extern void AllowPortraitDefault(portrait_params *portrait, bool32 allow); extern void WaitUntilAlertBoxTextIsLoaded(u32 param_1); -extern void AdvanceFrame(u32 param_1); void WaitUntilAlertBoxPauseIsOver(u32 param_1) { diff --git a/src/overlay_31_02382820.c b/src/overlay_31_02382820.c index b13811da..f06ab50e 100644 --- a/src/overlay_31_02382820.c +++ b/src/overlay_31_02382820.c @@ -9,6 +9,7 @@ #include "window.h" #include "main_02027AF0.h" #include "dungeon_util_2.h" +#include "overlay_29_022E9FC0.h" extern struct dungeon *DUNGEON_PTR[]; @@ -28,7 +29,6 @@ extern struct struct_1 OVERLAY31_UNKNOWN_STRUCT__NA_2389E30; extern u16 ov31_02389E22[]; -extern void* MemAlloc(u32 size, u32 nmemb); extern u32 GetMoneyCarried(void); extern u32 sub_0204F9E0(void); @@ -53,7 +53,6 @@ extern void CloseTextBox(s8); extern void CloseParentMenu(s8); extern void UnkMapRelatedFunc(u32, u32); -extern void AdvanceFrame(u8); extern u32 GetLeaderActionId(void); extern void ov29_022E0C2C(u32); diff --git a/src/overlay_31_02383880.c b/src/overlay_31_02383880.c index aa018b57..0452a00c 100644 --- a/src/overlay_31_02383880.c +++ b/src/overlay_31_02383880.c @@ -4,13 +4,13 @@ #include "overlay_31_02383478.h" #include "main_02001188.h" #include "main_020282F4.h" +#include "overlay_29_022E9FC0.h" extern struct dungeon *DUNGEON_PTR[]; extern struct loc_struct* OVERLAY31_UNKNOWN_POINTER__NA_238A26C; extern u8 PositionHasItem(struct position* pos); extern bool8 ov10_022BCD10(s8); -extern void AdvanceFrame(u8); extern void CloseInventoryMenu(s8); extern void ov29_0234E988(u8*); extern void CloseTextBox2(); diff --git a/src/type_effectiveness.c b/src/type_effectiveness.c index b9542329..4ddc0d23 100644 --- a/src/type_effectiveness.c +++ b/src/type_effectiveness.c @@ -12,11 +12,11 @@ #include "overlay_29_0233836C.h" #include "type_matchup_table.h" #include "weather.h" +#include "overlay_29_0234B340.h" extern struct dungeon *DUNGEON_PTR; extern bool8 UpdateStateFlags(struct monster *info, s32 flag, bool8 value); -extern void LogMessageByIdWithPopupCheckUserTarget(struct entity *user, struct entity *target, u32 message_id); extern void LogMessageByIdWithPopupCheckParticipants(struct entity *user, struct entity *target, u32 message_id, s32 a4, s32 a5); extern void MultiplyFixedPoint64(struct fixed_point_64 *out, const struct fixed_point_64 *a, const struct fixed_point_64 *b); extern bool8 GhostImmunityIsActive(struct entity *attacker, struct entity *defender, s16 target_type_idx);