diff --git a/include/code_8066D04.h b/include/code_8066D04.h deleted file mode 100644 index 227aa9bf3..000000000 --- a/include/code_8066D04.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef GUARD_CODE_8066D04_H -#define GUARD_CODE_8066D04_H - -void HandleSetItemAction(Entity *, bool8); - -#endif // GUARD_CODE_8066D04_H diff --git a/include/dungeon_action_handler.h b/include/dungeon_action_handler.h new file mode 100644 index 000000000..9816b3de8 --- /dev/null +++ b/include/dungeon_action_handler.h @@ -0,0 +1,24 @@ +#ifndef GUARD_DUNGEON_ACTION_HANDLER_H +#define GUARD_DUNGEON_ACTION_HANDLER_H + +#include "structs/dungeon_entity.h" + +void HandlePickUpPlayerAction(Entity *entity); +void HandleSetItemAction(Entity *param_1, bool8 param_2); +void HandleUnsetItemAction(Entity *entity, bool8 enableMessage); +void HandleGiveItemAction(Entity *param_1); +void HandleTakeItemAction(Entity *param_1); +void sub_8066BD4(Entity *param_1); +void HandleUseItemAction(Entity *param_1); +void HandlePlaceItemAction(Entity *entity); +void sub_8066E14(Entity *entity); +void sub_8066FA4(Entity *entity); +void sub_8067110(Entity *entity); +void sub_80671A0(Entity *entity); +void HandleTalkFieldAction(Entity *entity); +void sub_806752C(ActionContainer *a0); +void sub_8067768(ActionContainer *a0); +void HandleUseMovePlayerAction(Entity *entity); +void sub_8067904(Entity *entity, u16 moveId); + +#endif // GUARD_DUNGEON_ACTION_HANDLER_H diff --git a/include/dungeon_ai.h b/include/dungeon_ai.h index bed4431c0..72dab1808 100644 --- a/include/dungeon_ai.h +++ b/include/dungeon_ai.h @@ -4,5 +4,6 @@ #include "structs/dungeon_entity.h" void RunMonsterAI(Entity *pokemon, u32 unused); +void sub_8075BA4(Entity *param_1, u8 param_2); #endif diff --git a/include/dungeon_ai_attack.h b/include/dungeon_ai_attack.h index 8f5b31c83..70781a844 100644 --- a/include/dungeon_ai_attack.h +++ b/include/dungeon_ai_attack.h @@ -21,5 +21,8 @@ bool8 IsAITargetEligible(s32 targetingFlags, Entity *user, Entity *target, Move s32 WeightMove(Entity *user, s32 targetingFlags, Entity *target, u32 moveType); bool8 TargetRegularAttack(Entity *pokemon, u32 *targetDir, bool8 checkPetrified); bool8 IsTargetInRange(Entity *pokemon, Entity *targetPokemon, s32 direction, s32 maxRange); +void HandleUseMoveAIAction(Entity *target); +void HandleUseOrbAction(Entity *pokemon); +s16 GetMoveTargetAndRangeForPokemon(Entity *pokemon, Move *move, bool32 isAI); #endif diff --git a/include/dungeon_ai_items.h b/include/dungeon_ai_items.h index 960b33009..f9b36c588 100644 --- a/include/dungeon_ai_items.h +++ b/include/dungeon_ai_items.h @@ -8,5 +8,9 @@ void AIDecideUseItem(Entity *pokemon); void GetPossibleAIThrownItemDirections(Entity *pokemon, s32 thrownAIFlag, Item *item, bool8 ignoreRollChance); void GetPossibleAIArcItemTargets(Entity *pokemon, Item *item, DungeonPos potentialTargets[], bool8 ignoreRollChance); void TargetThrownItem(Entity *pokemon, Entity *targetPokemon, Item *item, s32 targetingFlags, bool8 ignoreRollChance); +void HandleEatAIAction(Entity *pokemon); +void HandleThrowItemAIAction(Entity *pokemon); +void HandlePickUpAIAction(Entity *pokemon); +void MonTryPickUpItem(Entity *entity); #endif diff --git a/include/dungeon_message.h b/include/dungeon_message.h index 54e7b1ab0..a69b2da2e 100644 --- a/include/dungeon_message.h +++ b/include/dungeon_message.h @@ -31,6 +31,7 @@ extern bool8 gUnknown_203B434; void sub_80521D0(void); void sub_8052210(bool8 a0); +void sub_805229C(void); // These functions display the string if certain conditions are met. The conditions differ depending on the function. The string is then saved to the message log. void LogMessageByIdWithPopupCheckUser(Entity *pokemon, const u8 *str); diff --git a/include/dungeon_misc.h b/include/dungeon_misc.h index 01823c666..1ce00a21b 100644 --- a/include/dungeon_misc.h +++ b/include/dungeon_misc.h @@ -55,6 +55,7 @@ void sub_806A1B0(Entity *pokemon); void sub_806A1E8(Entity *pokemon); void sub_806A240(Entity *pokemon, Entity *target); void TryPointCameraToMonster(Entity *pokemon, u8 param_2); +void nullsub_95(Entity *pokemon); void sub_806A338(void); void sub_806A390(Entity *pokemon); void sub_806A3D4(u8 *dst, s32 _a1, s32 id, bool32 _a3); diff --git a/include/dungeon_util.h b/include/dungeon_util.h index 0d9c4bb71..1a31a9e94 100644 --- a/include/dungeon_util.h +++ b/include/dungeon_util.h @@ -17,9 +17,13 @@ bool8 EntityIsValid(Entity *pokemon); u32 GetEntityType(Entity *entity); u8 GetEntityRoom(Entity *entity); Tile *GetTileAtEntitySafe(Entity *entity); +void sub_804513C(void); +void sub_804522C(void); void UpdateEntityPixelPos(Entity *entity, PixelPos *pos); void SetEntityPixelPos(Entity *entity, s32 x, s32 y); void IncreaseEntityPixelPos(Entity *entity, s32 x, s32 y); +Entity *sub_80453AC(s32 _species); +Entity *sub_804550C(s32 _species); Item *GetItemInfo(Entity *entity); Item *GetItemData_1(Entity *entity); Trap *GetTrapInfo(Entity *entity); @@ -27,6 +31,7 @@ Trap* GetTrapData_1(Entity *entity); Entity *SpawnTrap(u8 trapID, DungeonPos *pos, u8 c); Entity *SpawnItemEntity(DungeonPos *pos); void sub_80457DC(Entity* ent); +bool8 ShouldMinimapDisplayEntity(Entity *ent); bool8 ShouldDisplayEntity(Entity *ent); bool8 CanSeeTarget(Entity *entity, Entity *targetEntity); bool8 CanTargetEntity(Entity *entity, Entity *targetEntity); @@ -35,6 +40,7 @@ bool8 sub_8045AAC(Entity *entity, DungeonPos *pos); bool8 CanTargetPosition(Entity *entity, DungeonPos *pos); void SubstitutePlaceholderStringTags(u8 *buffer, Entity *entity, u32 param_3); void sub_8045ACC(void); +s32 GetTeamMemberEntityIndex(Entity *pokemon); extern u8 gUnknown_202EE70[MAX_TEAM_BODY_SIZE]; extern u8 gUnknown_202EE76[DUNGEON_MAX_WILD_POKEMON_BODY_SIZE]; diff --git a/include/status_checks.h b/include/status_checks.h index 22bd90d4a..071fcb388 100644 --- a/include/status_checks.h +++ b/include/status_checks.h @@ -3,8 +3,7 @@ #include "structs/dungeon_entity.h" -extern const s16 gConfusedAttackChance; - bool8 HasStatusThatPreventsActing(Entity *pokemon); +bool8 sub_80701A4(Entity *pokemon); #endif diff --git a/include/targeting_flags.h b/include/targeting_flags.h deleted file mode 100644 index 7960d5c0a..000000000 --- a/include/targeting_flags.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef GUARD_TARGETING_FLAGS_H -#define GUARD_TARGETING_FLAGS_H - -#include "constants/move.h" -#include "structs/dungeon_entity.h" - -s16 GetMoveTargetAndRangeForPokemon(Entity *pokemon, Move *move, bool32 isAI); - -#endif diff --git a/ld_script.ld b/ld_script.ld index cfdedf3d6..08e8c7451 100755 --- a/ld_script.ld +++ b/ld_script.ld @@ -232,7 +232,7 @@ SECTIONS { src/dungeon_menu_stairs.o(.text); src/dungeon_menu_others.o(.text); src/dungeon_menu_recruitment.o(.text); - src/code_8066D04.o(.text); + src/dungeon_action_handler.o(.text); src/dungeon_recruit_release_menu.o(.text); src/dungeon_misc.o(.text); src/dungeon_mon_spawn.o(.text); @@ -617,7 +617,7 @@ SECTIONS { src/dungeon_menu_stairs.o(.rodata); src/dungeon_menu_others.o(.rodata); src/dungeon_menu_recruitment.o(.rodata); - src/code_8066D04.o(.rodata); + src/dungeon_action_handler.o(.rodata); src/dungeon_recruit_release_menu.o(.rodata); src/dungeon_misc.o(.rodata); src/dungeon_mon_spawn.o(.rodata); diff --git a/src/dungeon_action_execution.c b/src/dungeon_action_execution.c index 783f5d583..bb3d50d2a 100644 --- a/src/dungeon_action_execution.c +++ b/src/dungeon_action_execution.c @@ -5,7 +5,7 @@ #include "dungeon_move_util.h" #include "dungeon_vram.h" #include "dungeon_8041AD0.h" -#include "code_8066D04.h" +#include "dungeon_action_handler.h" #include "dungeon_message.h" #include "constants/dungeon_action.h" #include "constants/dungeon.h" @@ -39,32 +39,10 @@ #include "move_orb_effects_1.h" #include "move_orb_effects_3.h" #include "dungeon_entity_movement.h" - -void sub_8075BA4(Entity *param_1, u8 param_2); -void nullsub_95(Entity *); -extern void sub_80671A0(Entity *); -extern void sub_8067110(Entity *); -void HandleUseMoveAIAction(Entity *target); -void sub_8041888(u8 param_1); -void sub_805EFB4(Entity *, u8); -void HandlePlaceItemAction(Entity *); -void HandlePickUpPlayerAction(Entity *); -void sub_8066E14(Entity * ); -void sub_8066BD4(Entity*); -void HandleTalkFieldAction(Entity *); -void HandleUseMovePlayerAction(Entity *); -void HandleUseOrbAction(Entity *); -void sub_8067904(Entity *, u32); -void HandleGiveItemAction(Entity *); -void HandleTakeItemAction(Entity *); -void HandleUseItemAction(Entity *); -void sub_8066FA4(Entity *); -void HandleUnsetItemAction(Entity *,bool8); -extern u8 DisplayActions(Entity *); -void sub_806A1E8(Entity *pokemon); -void HandlePickUpAIAction(Entity *pokemon); -void HandleThrowItemAIAction(Entity *pokemon); -void HandleEatAIAction(Entity *pokemon); +#include "dungeon_ai_items.h" +#include "dungeon_ai_attack.h" +#include "dungeon_ai.h" +#include "dungeon_main.h" EWRAM_DATA u8 gUnknown_202F32C = 0; EWRAM_DATA u8 gUnknown_202F32D = 0; diff --git a/src/code_8066D04.c b/src/dungeon_action_handler.c similarity index 98% rename from src/code_8066D04.c rename to src/dungeon_action_handler.c index b26c4797e..ca19263b2 100644 --- a/src/code_8066D04.c +++ b/src/dungeon_action_handler.c @@ -1,5 +1,6 @@ #include "global.h" #include "globaldata.h" +#include "dungeon_action_handler.h" #include "constants/dungeon.h" #include "constants/dungeon_exit.h" #include "constants/item.h" @@ -8,7 +9,6 @@ #include "dungeon_tilemap.h" #include "dungeon_8041AD0.h" #include "dungeon_action.h" -#include "code_8066D04.h" #include "dungeon_mon_sprite_render.h" #include "dungeon_jobs.h" #include "run_dungeon.h" @@ -46,9 +46,9 @@ #include "warp_target.h" #include "move_orb_effects_5.h" -Entity *sub_806773C(Entity *entity); -void sub_8067558(Entity *entity, Entity *targetEntity, s32 a2); -void sub_8067794(Entity *entity, Entity *targetEntity, s32 a2); +static void sub_8067558(Entity *entity, Entity *targetEntity, s32 a2); +static Entity *sub_806773C(Entity *entity); +static void sub_8067794(Entity *entity, Entity *targetEntity, s32 a2); void HandlePickUpPlayerAction(Entity *entity) { @@ -98,7 +98,7 @@ void HandleSetItemAction(Entity *param_1, bool8 param_2) } } -void HandleUnsetItemAction(Entity *entity,bool8 enableMessage) +void HandleUnsetItemAction(Entity *entity, bool8 enableMessage) { Item *item; int index; @@ -596,7 +596,7 @@ void sub_806752C(ActionContainer *a0) sub_8067558(GetLeader(), targetEntity, 0); } -void sub_8067558(Entity *entity, Entity *targetEntity, s32 a2) +static void sub_8067558(Entity *entity, Entity *targetEntity, s32 a2) { EntityInfo *info1 = GetEntInfo(entity); @@ -679,7 +679,7 @@ void sub_8067558(Entity *entity, Entity *targetEntity, s32 a2) } } -Entity *sub_806773C(Entity *entity) +static Entity *sub_806773C(Entity *entity) { Entity *ret = sub_80696A8(entity); if (ret == NULL) return NULL; @@ -695,7 +695,7 @@ void sub_8067768(ActionContainer *a0) sub_8067794(GetLeader(), targetEntity, 0); } -void sub_8067794(Entity *entity, Entity *targetEntity, s32 a2) +static void sub_8067794(Entity *entity, Entity *targetEntity, s32 a2) { const u8 *stringPtr1; const u8 *stringPtr2; diff --git a/src/dungeon_ai_attack.c b/src/dungeon_ai_attack.c index 3dc426d77..0b48ce4c1 100644 --- a/src/dungeon_ai_attack.c +++ b/src/dungeon_ai_attack.c @@ -27,7 +27,6 @@ #include "position_util.h" #include "status_checks.h" #include "structs/str_dungeon.h" -#include "targeting_flags.h" #include "dungeon_misc.h" #include "dungeon_pos_data.h" #include "dungeon_engine.h" @@ -45,8 +44,6 @@ EWRAM_DATA u8 gPotentialAttackTargetDirections[NUM_DIRECTIONS] = {0}; EWRAM_DATA s32 gPotentialAttackTargetWeights[NUM_DIRECTIONS] = {0}; EWRAM_DATA Entity *gPotentialTargets[NUM_DIRECTIONS] = {0}; -extern void sub_806A1B0(Entity *); - void ChooseAIMove(Entity *pokemon) { EntityInfo *pokemonInfo = GetEntInfo(pokemon); diff --git a/src/dungeon_ai_items.c b/src/dungeon_ai_items.c index a09671db2..f7a002344 100644 --- a/src/dungeon_ai_items.c +++ b/src/dungeon_ai_items.c @@ -25,9 +25,7 @@ #include "dungeon_items.h" #include "constants/dungeon.h" #include "dungeon_engine.h" - -extern void sub_8067110(Entity *); -extern void sub_80671A0(Entity *); +#include "dungeon_action_handler.h" #define NUM_POTENTIAL_ROCK_TARGETS 20 #define GROUND_ITEM_TOOLBOX_INDEX 0x80 @@ -45,10 +43,6 @@ EWRAM_DATA u32 gAIThrownItemDirections[NUM_DIRECTIONS] = {0}; EWRAM_DATA bool8 gAIThrownItemDirectionIsUsed[NUM_DIRECTIONS] = {0}; EWRAM_DATA u32 gAIThrownItemProbabilities[NUM_DIRECTIONS] = {0}; -extern TeamInventory *gTeamInventoryRef; - -void sub_8073D14(Entity *); - void AIDecideUseItem(Entity *pokemon) { EntityInfo *pokemonInfo = GetEntInfo(pokemon); @@ -429,10 +423,10 @@ void HandleThrowItemAIAction(Entity *pokemon) void HandlePickUpAIAction(Entity *pokemon) { - sub_8073D14(pokemon); + MonTryPickUpItem(pokemon); } -void sub_8073D14(Entity *entity) +void MonTryPickUpItem(Entity *entity) { Item *groundItem; EntityInfo *_entityInfo; diff --git a/src/dungeon_cutscene_articuno.c b/src/dungeon_cutscene_articuno.c index 15457e540..2777bf5bb 100644 --- a/src/dungeon_cutscene_articuno.c +++ b/src/dungeon_cutscene_articuno.c @@ -32,9 +32,6 @@ #include "dungeon_leveling.h" #include "weather.h" -extern void sub_8049884(void); -extern void sub_8049B8C(void); -extern void sub_8052D44(s16 *, Entity *, Entity *); static void sub_8088484(Entity *param_1); static void ArticunoScreenFlash(void); diff --git a/src/dungeon_cutscene_celebi.c b/src/dungeon_cutscene_celebi.c index e42c9fb75..ae939d673 100644 --- a/src/dungeon_cutscene_celebi.c +++ b/src/dungeon_cutscene_celebi.c @@ -33,9 +33,6 @@ #include "weather.h" #include "dungeon_mon_recruit.h" -extern void sub_8049884(void); -extern void sub_8049B8C(void); -extern void sub_8052D44(s16 *, Entity *, Entity *); static void sub_808C8E0(Entity *entity); static void sub_808C9B0(Entity *param_1); diff --git a/src/dungeon_cutscene_deoxys.c b/src/dungeon_cutscene_deoxys.c index 0c4f9aec0..9a991f3c5 100644 --- a/src/dungeon_cutscene_deoxys.c +++ b/src/dungeon_cutscene_deoxys.c @@ -31,9 +31,6 @@ #include "dungeon_boss_dialogue.h" -extern void sub_8049884(void); -extern void sub_8049B8C(void); -extern void sub_8052D44(s16 *, Entity *, Entity *); static void DeoxysScreenFlash(void); static void sub_808C550(void); diff --git a/src/dungeon_cutscene_entei.c b/src/dungeon_cutscene_entei.c index 7319d4832..c71550c82 100644 --- a/src/dungeon_cutscene_entei.c +++ b/src/dungeon_cutscene_entei.c @@ -30,9 +30,6 @@ #include "dungeon_config.h" #include "dungeon_boss_dialogue.h" -extern void sub_8049884(void); -extern void sub_8049B8C(void); -extern void sub_8052D44(s16 *, Entity *, Entity *); static void EnteiScreenFlash(void); diff --git a/src/dungeon_cutscene_groudon.c b/src/dungeon_cutscene_groudon.c index d9dbaad8c..c55bc85b9 100644 --- a/src/dungeon_cutscene_groudon.c +++ b/src/dungeon_cutscene_groudon.c @@ -32,9 +32,6 @@ #include "dungeon_tilemap.h" #include "dungeon_leveling.h" -extern void sub_8049884(void); -extern void sub_8049B8C(void); -extern void sub_8052D44(s16 *, Entity *, Entity *); static void SceneGroudonMovement(Entity * groudonEntity); static void GroudonScreenFlash(void); diff --git a/src/dungeon_cutscene_hooh.c b/src/dungeon_cutscene_hooh.c index 1a590bf58..48319bdde 100644 --- a/src/dungeon_cutscene_hooh.c +++ b/src/dungeon_cutscene_hooh.c @@ -30,9 +30,6 @@ #include "dungeon_config.h" #include "dungeon_boss_dialogue.h" -extern void sub_8049884(void); -extern void sub_8049B8C(void); -extern void sub_8052D44(s16 *, Entity *, Entity *); static void HoOhDropInEffect(Entity * param_1); static void HoOhScreenFlash(void); diff --git a/src/dungeon_cutscene_jirachi.c b/src/dungeon_cutscene_jirachi.c index 9c3d5635a..98193a369 100644 --- a/src/dungeon_cutscene_jirachi.c +++ b/src/dungeon_cutscene_jirachi.c @@ -34,9 +34,6 @@ #include "dungeon_mon_spawn.h" #include "dungeon_8041AD0.h" -extern void sub_8049884(void); -extern void sub_8049B8C(void); -extern void sub_8052D44(s16 *, Entity *, Entity *); static void sub_808B50C(void); static void JirachiWish(void); diff --git a/src/dungeon_cutscene_kyogre.c b/src/dungeon_cutscene_kyogre.c index 6c7a1803e..18c5e8be9 100644 --- a/src/dungeon_cutscene_kyogre.c +++ b/src/dungeon_cutscene_kyogre.c @@ -32,9 +32,6 @@ #include "dungeon_tilemap.h" #include "dungeon_map.h" -extern void sub_8049884(void); -extern void sub_8049B8C(void); -extern void sub_8052D44(s16 *, Entity *, Entity *); static void nullsub_99(void); static void KyogreScreenFlash(void); diff --git a/src/dungeon_cutscene_latios.c b/src/dungeon_cutscene_latios.c index efd61c979..5136c8263 100644 --- a/src/dungeon_cutscene_latios.c +++ b/src/dungeon_cutscene_latios.c @@ -31,9 +31,6 @@ #include "dungeon_boss_dialogue.h" -extern void sub_8049884(void); -extern void sub_8049B8C(void); -extern void sub_8052D44(s16 *, Entity *, Entity *); static void LatiosScreenFlash(void); diff --git a/src/dungeon_cutscene_lugia.c b/src/dungeon_cutscene_lugia.c index cdf7e36d7..f34abfa65 100644 --- a/src/dungeon_cutscene_lugia.c +++ b/src/dungeon_cutscene_lugia.c @@ -31,9 +31,6 @@ #include "dungeon_boss_dialogue.h" -extern void sub_8049884(void); -extern void sub_8049B8C(void); -extern void sub_8052D44(s16 *, Entity *, Entity *); static void LugiaScreenFlash(void); static void LugiaScreenFlash2(void); diff --git a/src/dungeon_cutscene_magma_cavern.c b/src/dungeon_cutscene_magma_cavern.c index abb7ec563..143a007d8 100644 --- a/src/dungeon_cutscene_magma_cavern.c +++ b/src/dungeon_cutscene_magma_cavern.c @@ -30,9 +30,6 @@ #include "dungeon_config.h" #include "dungeon_boss_dialogue.h" -extern void sub_8049884(void); -extern void sub_8049B8C(void); -extern void sub_8052D44(s16 *, Entity *, Entity *); static void sub_80891F0(void); static void sub_8089294(void); diff --git a/src/dungeon_cutscene_mankey.c b/src/dungeon_cutscene_mankey.c index 066949a58..5960cfe8f 100644 --- a/src/dungeon_cutscene_mankey.c +++ b/src/dungeon_cutscene_mankey.c @@ -30,9 +30,6 @@ #include "dungeon_config.h" #include "dungeon_boss_dialogue.h" -extern void sub_8049884(void); -extern void sub_8049B8C(void); -extern void sub_8052D44(s16 *, Entity *, Entity *); static void sub_80898F8(Entity *r0); static void sub_8089908(Entity *r0); diff --git a/src/dungeon_cutscene_meanies.c b/src/dungeon_cutscene_meanies.c index 16423a3ea..180d18910 100644 --- a/src/dungeon_cutscene_meanies.c +++ b/src/dungeon_cutscene_meanies.c @@ -29,9 +29,6 @@ #include "dungeon_config.h" #include "dungeon_boss_dialogue.h" -extern void sub_8049884(void); -extern void sub_8049B8C(void); -extern void sub_8052D44(s16 *, Entity *, Entity *); static void sub_8087144(void); diff --git a/src/dungeon_cutscene_medicham.c b/src/dungeon_cutscene_medicham.c index 2949d3b9c..3909a66b9 100644 --- a/src/dungeon_cutscene_medicham.c +++ b/src/dungeon_cutscene_medicham.c @@ -30,9 +30,6 @@ #include "dungeon_config.h" #include "dungeon_boss_dialogue.h" -extern void sub_8049884(void); -extern void sub_8049B8C(void); -extern void sub_8052D44(s16 *, Entity *, Entity *); void sub_808C9C4(void) { diff --git a/src/dungeon_cutscene_mewtwo.c b/src/dungeon_cutscene_mewtwo.c index 833f0d33c..df90972ac 100644 --- a/src/dungeon_cutscene_mewtwo.c +++ b/src/dungeon_cutscene_mewtwo.c @@ -30,9 +30,6 @@ #include "dungeon_config.h" #include "dungeon_boss_dialogue.h" -extern void sub_8049884(void); -extern void sub_8049B8C(void); -extern void sub_8052D44(s16 *, Entity *, Entity *); static void MewtwoDropInEffect(Entity *mewtwoEntity); static void MewtwoScreenFlash(void); diff --git a/src/dungeon_cutscene_moltres.c b/src/dungeon_cutscene_moltres.c index 8e8133c24..d1064d6e6 100644 --- a/src/dungeon_cutscene_moltres.c +++ b/src/dungeon_cutscene_moltres.c @@ -32,9 +32,6 @@ #include "dungeon_tilemap.h" #include "dungeon_leveling.h" -extern void sub_8049884(void); -extern void sub_8049B8C(void); -extern void sub_8052D44(s16 *, Entity *, Entity *); static void MoltresDropInEffect(Entity * moltresEntity); static void MoltresScreenFlash1(s32 xArg, s32 yArg); diff --git a/src/dungeon_cutscene_raikou.c b/src/dungeon_cutscene_raikou.c index 95b30d259..497828fe7 100644 --- a/src/dungeon_cutscene_raikou.c +++ b/src/dungeon_cutscene_raikou.c @@ -31,9 +31,6 @@ #include "dungeon_boss_dialogue.h" #include "weather.h" -extern void sub_8049884(void); -extern void sub_8049B8C(void); -extern void sub_8052D44(s16 *, Entity *, Entity *); static void RaikouScreenFlash(void); diff --git a/src/dungeon_cutscene_rayquaza.c b/src/dungeon_cutscene_rayquaza.c index 7d98bbd52..17717c4a6 100644 --- a/src/dungeon_cutscene_rayquaza.c +++ b/src/dungeon_cutscene_rayquaza.c @@ -31,9 +31,6 @@ #include "dungeon_boss_dialogue.h" #include "dungeon_leveling.h" -extern void sub_8049884(void); -extern void sub_8049B8C(void); -extern void sub_8052D44(s16 *, Entity *, Entity *); static void RayquazaDropInEffect(Entity *rayquazaEntity); static void RayquazaScreenFlash(void); diff --git a/src/dungeon_cutscene_regis.c b/src/dungeon_cutscene_regis.c index 1aff0cf65..8040ea9f5 100644 --- a/src/dungeon_cutscene_regis.c +++ b/src/dungeon_cutscene_regis.c @@ -31,9 +31,6 @@ #include "dungeon_boss_dialogue.h" #include "dungeon_map.h" -extern void sub_8049884(void); -extern void sub_8049B8C(void); -extern void sub_8052D44(s16 *, Entity *, Entity *); static void sub_808B1CC(u8 itemID); static void SetupRegiFacingDirection(Entity *regiEntity); diff --git a/src/dungeon_cutscene_skarmory.c b/src/dungeon_cutscene_skarmory.c index 3cf446119..dfbaf6d50 100644 --- a/src/dungeon_cutscene_skarmory.c +++ b/src/dungeon_cutscene_skarmory.c @@ -30,9 +30,6 @@ #include "dungeon_config.h" #include "dungeon_boss_dialogue.h" -extern void sub_8049884(void); -extern void sub_8049B8C(void); -extern void sub_8052D44(s16 *, Entity *, Entity *); static void SkarmoryEntry(Entity * skarmoryEntity); diff --git a/src/dungeon_cutscene_smeargle.c b/src/dungeon_cutscene_smeargle.c index 707f74367..04d98233f 100644 --- a/src/dungeon_cutscene_smeargle.c +++ b/src/dungeon_cutscene_smeargle.c @@ -30,9 +30,6 @@ #include "dungeon_config.h" #include "dungeon_boss_dialogue.h" -extern void sub_8049884(void); -extern void sub_8049B8C(void); -extern void sub_8052D44(s16 *, Entity *, Entity *); void DummyFightDialogue(void) { diff --git a/src/dungeon_cutscene_suicune.c b/src/dungeon_cutscene_suicune.c index 1931c8c97..412128ace 100644 --- a/src/dungeon_cutscene_suicune.c +++ b/src/dungeon_cutscene_suicune.c @@ -30,9 +30,6 @@ #include "dungeon_config.h" #include "dungeon_boss_dialogue.h" -extern void sub_8049884(void); -extern void sub_8049B8C(void); -extern void sub_8052D44(s16 *, Entity *, Entity *); static void sub_808A528(Entity * param_1); static void SuicuneScreenFlash(void); diff --git a/src/dungeon_cutscene_zapdos.c b/src/dungeon_cutscene_zapdos.c index 9f4d87768..d37942aa8 100644 --- a/src/dungeon_cutscene_zapdos.c +++ b/src/dungeon_cutscene_zapdos.c @@ -31,9 +31,6 @@ #include "dungeon_boss_dialogue.h" #include "dungeon_leveling.h" -extern void sub_8049884(void); -extern void sub_8049B8C(void); -extern void sub_8052D44(s16 *, Entity *, Entity *); struct Zapdos1 { diff --git a/src/dungeon_damage.c b/src/dungeon_damage.c index e18f29ae7..901e65496 100644 --- a/src/dungeon_damage.c +++ b/src/dungeon_damage.c @@ -47,13 +47,8 @@ #include "move_orb_actions_1.h" #include "move_orb_effects_2.h" #include "move_orb_effects_5.h" - -extern void sub_803ED30(s32, Entity *r0, u8, s32); -extern bool8 sub_806A458(Entity *); -extern bool8 sub_806A58C(s16 a0); -extern void sub_806A390(Entity *r0); -extern void sub_800DBBC(void); -extern void PointCameraToMonster(Entity *); +#include "dungeon_tilemap.h" +#include "effect_main.h" static bool8 HandleDealingDamageInternal(Entity *attacker, Entity *target, struct DamageStruct *r5, bool32 isFalseSwipe, bool32 giveExp, s16 dungeonExitReason_, s32 arg8); static bool8 sub_806E100(s48_16 *param_1, Entity *pokemon, Entity *target, u8 type, DamageStruct *dmgStruct); diff --git a/src/dungeon_engine.c b/src/dungeon_engine.c index 2ea014d0c..ad5c4024f 100644 --- a/src/dungeon_engine.c +++ b/src/dungeon_engine.c @@ -23,8 +23,6 @@ #include "dungeon_entity_movement.h" #include "dungeon_wind.h" -extern void sub_805F02C(void); - static void sub_8044454(void); static bool8 RunLeaderTurn(bool8); static void sub_8044574(void); diff --git a/src/dungeon_entity_movement.c b/src/dungeon_entity_movement.c index cda0ccb77..a02a6941d 100644 --- a/src/dungeon_entity_movement.c +++ b/src/dungeon_entity_movement.c @@ -53,6 +53,7 @@ #include "dungeon_tilemap.h" #include "run_dungeon.h" #include "dungeon_8041AD0.h" +#include "dungeon_ai_items.h" static EWRAM_DATA s32 sSpeedMultiplier = 0; @@ -60,8 +61,6 @@ static void sub_8075050(EntityInfo *info, Unk_Entity_x184 *strPtr); static void nullsub_97(Entity *entity); static void TryInteractWithTile(Entity *entity); -extern void sub_8073D14(Entity *entity); - static inline void SetSpeedMultiplier(void) { if (gGameOptionsRef->dungeonSpeed != 0) @@ -392,7 +391,7 @@ static void TryInteractWithTile(Entity *entity) break; } case ENTITY_ITEM: - sub_8073D14(entity); + MonTryPickUpItem(entity); break; case ENTITY_NOTHING: case ENTITY_MONSTER: diff --git a/src/dungeon_generation.c b/src/dungeon_generation.c index 750e3dc01..bf247b6f9 100644 --- a/src/dungeon_generation.c +++ b/src/dungeon_generation.c @@ -22,11 +22,6 @@ #include "dungeon_mon_spawn.h" #include "run_dungeon.h" -extern s32 sub_803DA20(s16 species); -extern void sub_8049840(void); -extern void sub_80498A8(s32, s32); -extern void sub_8049B8C(void); - enum CardinalDirection { CARDINAL_DIR_RIGHT, diff --git a/src/dungeon_leveling.c b/src/dungeon_leveling.c index 359cda84f..304bffda6 100644 --- a/src/dungeon_leveling.c +++ b/src/dungeon_leveling.c @@ -32,8 +32,6 @@ static EWRAM_DATA s32 sNewAtkStats[2] = {0, 0}; static EWRAM_DATA s32 sNewDefStats[2] = {0, 0}; -void sub_8042A44(Entity *r0); - static const u8 gUnknown_8107010[8] = {0, 1, 1, 2, 1, 1, 0, 0}; static const u8 * const gUnknown_8107018[3] = { _(""), diff --git a/src/dungeon_main.c b/src/dungeon_main.c index 2c545c364..22034d0c7 100644 --- a/src/dungeon_main.c +++ b/src/dungeon_main.c @@ -18,7 +18,7 @@ #include "dungeon_vram.h" #include "dungeon_tilemap.h" #include "dungeon_action.h" -#include "code_8066D04.h" +#include "dungeon_action_handler.h" #include "dungeon_mon_sprite_render.h" #include "dungeon_action.h" #include "dungeon_ai_movement.h" @@ -61,21 +61,9 @@ #include "dungeon_strings.h" #include "dungeon_entity_movement.h" #include "dungeon_8041AD0.h" +#include "status_checks.h" -extern void HandleUnsetItemAction(Entity *,bool8); -extern void TryTriggerTrap(Entity *pokemon, DungeonPos *pos, int param_3, char param_4); -void TryPointCameraToMonster(Entity *a0, u8 a1); -bool8 sub_80701A4(Entity *a0); -void ClearUnpaidFlagFromAllItems(void); -void sub_806A914(u8 a0, u8 a1, u8 a2); -u16 GetLeaderActionId(void); void sub_80978C8(s16 a0); -void HandleTalkFieldAction(Entity *); -s32 GetTeamMemberEntityIndex(Entity *pokemon); -bool8 sub_8070F80(Entity * pokemon, s32 direction); -void sub_806752C(ActionContainer *a0); -void sub_8067768(ActionContainer *a0); -extern bool8 sub_8071A8C(Entity *pokemon); static EWRAM_DATA bool8 sInDiagonalMode = 0; static EWRAM_DATA bool8 sInRotateMode = 0; diff --git a/src/dungeon_map.c b/src/dungeon_map.c index b712dbdaa..a99f45c2c 100644 --- a/src/dungeon_map.c +++ b/src/dungeon_map.c @@ -23,8 +23,6 @@ #include "trap.h" #include "run_dungeon.h" -extern bool8 ShouldMinimapDisplayEntity(Entity *ent); - struct UnkStruct1 { u32 **unk0; diff --git a/src/dungeon_menu_moves.c b/src/dungeon_menu_moves.c index 3a6a078fa..ae251cf4d 100644 --- a/src/dungeon_menu_moves.c +++ b/src/dungeon_menu_moves.c @@ -30,13 +30,6 @@ #include "text_2.h" #include "text_3.h" -extern s32 GetTeamMemberEntityIndex(Entity *pokemon); -extern void sub_806752C(ActionContainer *a0); -extern void ShowDungeonSummaryOrIQMenu(ActionContainer *a0, bool8 a1); -extern void sub_8067768(ActionContainer *a0); -extern bool8 sub_8071A8C(Entity *pokemon); - - static void ShowMovesMenuWindows(Entity *entity, EntityInfo *entInfo, bool8 redColorForChargingMoves, WindowTemplates *windows, WindowHeader *header, u8 *arg5, s32 arg6, s32 arg7); static void AddMovesSubMenuOptions(Entity *entity, bool8 addLinkOptions, bool8 addUseMove); static void SetSubMenuOptionAction(ActionContainer *a0, s32 a1, s32 a2); diff --git a/src/dungeon_menu_others.c b/src/dungeon_menu_others.c index 488ec37c8..bb100322c 100644 --- a/src/dungeon_menu_others.c +++ b/src/dungeon_menu_others.c @@ -32,10 +32,6 @@ #include "text_3.h" #include "run_dungeon.h" -extern bool8 IsFloorwideFixedRoom(void); -extern u16 GetLeaderActionId(void); - - static void PrintOthersMenuOptions(void); static void ShowGameOptionsMenu(void); static void ShowQuickSaveGiveUpMenu(void); diff --git a/src/dungeon_misc.c b/src/dungeon_misc.c index 90742c275..0645fdc78 100644 --- a/src/dungeon_misc.c +++ b/src/dungeon_misc.c @@ -55,24 +55,10 @@ #include "move_orb_effects_5.h" #include "dungeon_recruit_release_menu.h" #include "dungeon_8041AD0.h" +#include "dungeon_pokemon_sprites.h" static void EnsureCastformLoaded(void); static void EnsureDeoxysLoaded(void); - -extern bool8 sub_806A58C(s16 r0); -extern bool8 sub_8070F80(Entity * pokemon, s32 direction); -extern s32 sub_806A4DC(EntityInfo *info); -extern s16 sub_803D970(u32); -extern bool8 sub_80860A8(u8 id); -extern u8 sub_803D73C(s32 a0); -extern void DeletePokemonDungeonSprite(s32 id); -extern s32 sub_803DA20(s32 param_1); -extern Entity *sub_804550C(s16 a); -extern Entity *sub_80453AC(s16 id); - -extern u8 gUnknown_202F32C; - -bool8 sub_806A564(s16 r0); static bool8 sub_806A5A4(s16 r0); void OpenDungeonPaletteFile(void) @@ -1282,7 +1268,7 @@ void TryPointCameraToMonster(Entity *pokemon, u8 param_2) } } -void nullsub_95(void) +void nullsub_95(Entity *pokemon) {} void ReevaluateSnatchMonster(void) @@ -1512,8 +1498,6 @@ void sub_806A6E8(Entity *entity) } } -void DisplayMsgIfNewIqSkillLearned(EntityInfo *info, s32 pokeIq); - UNUSED static void DisplayMsgIfTeamMonsLearnedNewIqSkill(void) { s32 i; diff --git a/src/dungeon_mon_spawn.c b/src/dungeon_mon_spawn.c index 2308e5e07..113bc0baf 100644 --- a/src/dungeon_mon_spawn.c +++ b/src/dungeon_mon_spawn.c @@ -37,11 +37,8 @@ #include "dungeon_engine.h" #include "dungeon_leveling.h" #include "dungeon_8041AD0.h" - -extern bool8 sub_80860A8(u8 id); -extern u8 gUnknown_202F32C; -extern Entity *sub_804550C(s16 a); -extern Entity *sub_80453AC(s16 id); +#include "dungeon_cutscene.h" +#include "dungeon_action_execution.h" static s32 CalcSpeciesHPAtLevel(s32 species, s32 level); static s32 CalcSpeciesAtkAtLevel(s32 species, s32 level, s32 categoryIndex); diff --git a/src/dungeon_move.c b/src/dungeon_move.c index e1cb56fc0..decdf3a18 100644 --- a/src/dungeon_move.c +++ b/src/dungeon_move.c @@ -38,19 +38,12 @@ #include "position_util.h" #include "sprite.h" #include "weather.h" -#include "targeting_flags.h" #include "text_util.h" #include "dungeon_pos_data.h" #include "dungeon_engine.h" #include "warp_target.h" +#include "dungeon_ai_attack.h" -extern s16 GetDungeonExitReasonFromMoveOrItem(Move *move, s32 itemID); -extern void sub_806A1E8(Entity *pokemon); -extern bool8 sub_8040BB0(Entity *entity, Move *move, bool8); -extern void sub_8040DA0(Entity *entity, Move *move); -extern u16 GetEffectiveMoveId(u16 moveId, u8 weather, u8 hasSpecialEffect); -extern void sub_800EF10(u16 r0); -extern void sub_800E3AC(s32 a0, DungeonPos *pos, s32 a2); extern void sub_8041168(Entity *entity, Entity *entity2, Move *,DungeonPos *); static s32 TryHitTarget(Entity *attacker, Entity *target, Move *move, struct DamageStruct *dmgStruct, s16 unk_); diff --git a/src/dungeon_move_util.c b/src/dungeon_move_util.c index 36d9f37eb..9f342f2de 100644 --- a/src/dungeon_move_util.c +++ b/src/dungeon_move_util.c @@ -36,7 +36,7 @@ #include "move_orb_effects_3.h" #include "move_orb_effects_5.h" #include "weather.h" -#include "targeting_flags.h" +#include "dungeon_ai_attack.h" #include "pokemon_types.h" #include "dungeon_run_end.h" #include "dungeon_pos_data.h" @@ -44,12 +44,9 @@ #include "dungeon_damage.h" #include "dungeon_leveling.h" -extern void sub_806A1E8(Entity *pokemon); extern bool8 sub_8040BB0(Entity *entity, Move *move, bool8); extern void sub_8040DA0(Entity *entity, Move *move); extern u16 GetEffectiveMoveId(u16 moveId, u8 weather, u8 hasSpecialEffect); -extern void sub_800EF10(u16 r0); -extern void sub_800E3AC(s32 a0, DungeonPos *pos, s32 a2); extern void sub_8041168(Entity *entity, Entity *entity2, Move *,DungeonPos *); static u8 ToItemID(u32 itemID); diff --git a/src/dungeon_recruit_release_menu.c b/src/dungeon_recruit_release_menu.c index ff7e93141..aa6de89d4 100644 --- a/src/dungeon_recruit_release_menu.c +++ b/src/dungeon_recruit_release_menu.c @@ -7,7 +7,6 @@ #include "dungeon_tilemap.h" #include "dungeon_8041AD0.h" #include "dungeon_action.h" -#include "code_8066D04.h" #include "dungeon_mon_sprite_render.h" #include "run_dungeon.h" #include "dungeon_items.h" diff --git a/src/dungeon_turn_effects.c b/src/dungeon_turn_effects.c index 05aa73222..8acbab2f6 100644 --- a/src/dungeon_turn_effects.c +++ b/src/dungeon_turn_effects.c @@ -42,9 +42,7 @@ #include "move_orb_effects_5.h" #include "dungeon_8041AD0.h" #include "dungeon_entity_movement.h" - -extern void sub_805229C(void); -extern void sub_805E804(void); +#include "dungeon_main.h" void ApplyEndOfTurnEffects(Entity *entity) { diff --git a/src/dungeon_vram.c b/src/dungeon_vram.c index e4677629c..54dcaa10e 100644 --- a/src/dungeon_vram.c +++ b/src/dungeon_vram.c @@ -33,6 +33,8 @@ #include "dungeon_engine.h" #include "dungeon_cutscene.h" #include "effect_main.h" +#include "dungeon_mon_sprite_render.h" +#include "dungeon_8041AD0.h" // File split is correct. This technical file deals with windows, advancing frames(v-blanks) and vram / pal set-up. @@ -47,10 +49,6 @@ extern struct DungeonPalFile *gUnknown_202EC94; extern RGB gUnknown_202ECA4[]; extern OpenedFile *gUnknown_202EC9C; -void sub_806CC10(); -void sub_804522C(); -void sub_8042E5C(); - static void sub_803E490(u32); static void sub_803EC94(void); static void sub_803ECE0(void); diff --git a/src/friend_rescue.c b/src/friend_rescue.c index 9750c5134..7e53bc290 100644 --- a/src/friend_rescue.c +++ b/src/friend_rescue.c @@ -31,9 +31,6 @@ extern void SetFriendRescueMenuState(u32); -extern TeamInventory *gTeamInventoryRef; - - // NOTE: MenuItems and WindowTemplate defined in here.. #include "data/friend_rescue_menus.h" diff --git a/src/ground_link.c b/src/ground_link.c index 7189454ac..6c9667914 100644 --- a/src/ground_link.c +++ b/src/ground_link.c @@ -3,38 +3,37 @@ #include "ground_link.h" #include "debug.h" #include "ground_script.h" +#include "ground_script_file.h" #include "number_util.h" -EWRAM_INIT const struct GroundLink *gCurrentGroundLink = NULL; -extern DebugLocation gUnknown_8118798; -extern const struct GroundScriptHeader *GetGroundScript(s16 r0, DebugLocation *r1); +EWRAM_INIT static const struct GroundLink *sCurrentGroundLink = NULL; -void sub_80AD868(void) +UNUSED static void sub_80AD868(void) { - gCurrentGroundLink = NULL; + sCurrentGroundLink = NULL; } -void sub_80AD874(void) +UNUSED static void sub_80AD874(void) { - gCurrentGroundLink = NULL; + sCurrentGroundLink = NULL; } void GroundLink_Select(s16 r0) { const struct GroundScriptHeader *gs = GetGroundScript(r0, DEBUG_LOC_PTR("../ground/ground_link.c", 77, "GroundLink_Select")); - gCurrentGroundLink = gs->links; + sCurrentGroundLink = gs->links; } -const struct GroundLink *GetCurrentGroundLink(s16 r0) +UNUSED static const struct GroundLink *GetCurrentGroundLink(s16 r0) { u32 a = r0; - return &gCurrentGroundLink[a]; + return &sCurrentGroundLink[a]; } s32 GroundLink_GetPos(s32 _arg0, PixelPos *pos) { s32 arg0 = (s16)(_arg0); - const struct GroundLink *ptr = &gCurrentGroundLink[arg0]; + const struct GroundLink *ptr = &sCurrentGroundLink[arg0]; SetUnkInGroundEvent(&ptr->pos, pos); @@ -44,7 +43,7 @@ s32 GroundLink_GetPos(s32 _arg0, PixelPos *pos) s32 GroundLink_GetArea(s32 _arg0, PixelPos *arg1, PixelPos *arg2, PixelPos *arg3) { s32 arg0 = (s16) _arg0; - const struct GroundLink *ptr = &gCurrentGroundLink[arg0]; + const struct GroundLink *ptr = &sCurrentGroundLink[arg0]; *arg1 = *arg3; diff --git a/src/ground_main.c b/src/ground_main.c index bcf6247c8..031e15197 100644 --- a/src/ground_main.c +++ b/src/ground_main.c @@ -71,7 +71,6 @@ extern void sub_809975C(void); extern void sub_8099BE4(void); extern void sub_8099744(void); extern void WaitForNextFrameAndAdvanceRNG(void); -extern void LoadBufferedInputs(void); extern void sub_8099750(void); extern void nullsub_16(void); extern void UpdateAdventureAchievements(void); diff --git a/src/run_dungeon.c b/src/run_dungeon.c index 96ecec69b..3ebf50053 100644 --- a/src/run_dungeon.c +++ b/src/run_dungeon.c @@ -61,6 +61,7 @@ #include "dungeon_action_execution.h" #include "dungeon_8041AD0.h" #include "ground_main.h" +#include "dungeon_mon_sprite_render.h" EWRAM_INIT struct UnkStruct_203B414 *gUnknown_203B414 = NULL; EWRAM_INIT Dungeon *gDungeon = NULL; @@ -68,7 +69,6 @@ static EWRAM_INIT u8 *gSerializedData_203B41C = NULL; extern void sub_8068BDC(u8 r0); extern void sub_803D4AC(void); -extern void sub_804513C(void); extern void sub_8068F28(void); extern void IncrementThievingSuccesses(void); extern void sub_8043D60(void); @@ -84,16 +84,9 @@ extern void ReevaluateSnatchMonster(void); extern void sub_8051E3C(void); extern void sub_807FA18(void); extern void sub_806A974(void); -extern void DetermineAllMonsterShadow(void); extern void sub_8068F80(void); -extern bool8 TryForcedLoss(bool8); extern void sub_806A914(bool8 a0, bool8 a1, bool8 showRunAwayEffect); -extern u8 gUnknown_202F1A8; - -void EnforceMaxItemsAndMoney(void); -static void sub_8043FD0(void); - extern OpenedFile *gDungeonNameBannerPalette; // These functions are not part of dungeon's overlay5 and connect, in a way, overworld with dungeon. @@ -101,6 +94,7 @@ extern OpenedFile *gDungeonNameBannerPalette; static const s16 sDeoxysForms[4] = {MONSTER_DEOXYS_NORMAL, MONSTER_DEOXYS_ATTACK, MONSTER_DEOXYS_DEFENSE, MONSTER_DEOXYS_SPEED}; static void sub_8043CD8(void); +static void sub_8043FD0(void); // Actual function in Sky. Macro instead of static inline for matching #define GetForcedLossReason()(gDungeon->unk10) diff --git a/src/trap.c b/src/trap.c index 549588545..120bdfe23 100644 --- a/src/trap.c +++ b/src/trap.c @@ -39,9 +39,6 @@ #include "move_orb_effects_2.h" #include "move_orb_effects_4.h" -void sub_806A1E8(Entity *pokemon); -Entity *sub_8045684(u8, DungeonPos *, u8); - void sub_807FA18(void) { s32 x, y; diff --git a/sym_ewram.txt b/sym_ewram.txt index 8ea49be54..283f7c7de 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -49,7 +49,6 @@ .space 4 .include "src/dungeon_menu_others.o" .include "src/dungeon_menu_recruitment.o" - .include "src/code_8066D04.o" .include "src/dungeon_recruit_release_menu.o" .include "src/dungeon_logic.o" .include "src/dungeon_leveling.o"