From d1780e5928491a7de7342e3cffa1af5e41e7e3c8 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 30 Aug 2025 18:10:12 +0200 Subject: [PATCH] pokemon.c externs --- include/pokemon.h | 87 +++++++++++++++++++---------------- src/dungeon_leveling.c | 2 - src/dungeon_menu_team.c | 3 -- src/dungeon_misc.c | 1 - src/friend_area_action_menu.c | 2 - src/friend_list.c | 2 - src/ground_lives.c | 2 - src/ground_sprite.c | 4 +- src/ground_sprite_monster.c | 1 - src/party_list_menu.c | 2 - src/pokemon.c | 70 ++++++++++++++-------------- src/run_dungeon.c | 1 - 12 files changed, 84 insertions(+), 93 deletions(-) diff --git a/include/pokemon.h b/include/pokemon.h index a5281b58f..92a003c75 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -37,24 +37,44 @@ extern RecruitedMon *gRecruitedPokemonRef; void LoadMonsterParameters(void); RecruitedMon *GetRecruitedPokemon(void); void InitializeRecruitedPokemon(void); - - -u8 GetBodySize(s32 index); -void CopyMonsterNameToBuffer(u8 * buffer, s32 index); -void CopyYellowMonsterNametoBuffer(u8 *buffer, s16 index); -void CopyCyanMonsterNametoBuffer(u8 *buffer, s32 index_); -void PrintColoredPokeNameToBuffer(u8 *buffer, Pokemon *pokemon, s32 colorNum); -void sub_808D930(u8 *buffer, s32 index); -void sub_808D9DC(u8 *buffer, DungeonMon *, s32 colorNum); -void sub_808DA0C(u8 *buffer, DungeonMon *); +void sub_808CE74(s16 _species, bool32 _isLeader, u8* name); +void CreateLevel1Pokemon(Pokemon *pokemon, s16 _species, u8* name, u32 _itemID, const DungeonLocation *location, u16 *moves); +void sub_808D0D8(Pokemon *pokemon); +void ConvertStoryMonToPokemon(Pokemon *dst, const struct StoryMonData *src); +Pokemon *TryAddPokemonToRecruited(Pokemon*); +Pokemon *sub_808D278(s32 species); +Pokemon *TryAddLevel1PokemonToRecruited(s32 species, u8 *name, u32 _itemID, const DungeonLocation *location, u16 *moveID); +void sub_808D31C(Pokemon *param_1); +Pokemon *GetPlayerPokemonStruct(void); +Pokemon *sub_808D378(void); +Pokemon *sub_808D3BC(void); +Pokemon *sub_808D3F8(void); +Pokemon *GetRecruitedMonBySpecies(s16 species_, s32 sameSpeciesCounter); +s32 GetFriendSum_808D480(void); +bool8 sub_808D4B0(void); +bool8 sub_808D500(void); +s32 GetUnitSum_808D544(s32 *team); +s32 sub_808D580(s32 *team); +s32 sub_808D654(s32 *ptr); +s32 sub_808D6A4(s32 *ptr); +bool8 sub_808D750(s32 index_); void PeekPokemonItem(s16 index_, BulkItem* item); void GivePokemonItem(s16 index_, BulkItem* item); bool8 IsPokemonRenamed(Pokemon* pokemon); -bool8 CanMonLearnMove(u16 moveID, s16 _species); - -u8 *GetCategoryString(s16 index); -u8 GetShadowSize(s16 index); +bool8 ComparePokemonNames(s16, s16); +void CopyMonsterNameToBuffer(u8 * buffer, s32 index); +void CopyYellowMonsterNametoBuffer(u8 *buffer, s16 index); +void CopyCyanMonsterNametoBuffer(u8 *buffer, s32 index_); +void sub_808D930(u8 *buffer, s32 index); char * GetMonSpecies(s16 index); +void PrintColoredPokeNameToBuffer(u8 *buffer, Pokemon *pokemon, s32 colorNum); +void sub_808D9DC(u8 *buffer, DungeonMon *, s32 colorNum); +void sub_808DA0C(u8 *buffer, DungeonMon *); +void PrintPokeNameToBuffer(u8 *buffer, Pokemon *pokemon); +bool8 sub_808DA44(s32 _species, u32 a2_); +u8 *GetCategoryString(s16 index); +u8 GetBodySize(s32 index); +u8 GetShadowSize(s16 index); s32 GetMovementSpeed(s16 index); u8 GetMovementType(s16 index); u8 GetRegenSpeed(s16 index); @@ -78,39 +98,26 @@ s16 GetInternalNo(s16 index); s32 CalculateEXPGain(s16 index, s32 level); s16 GetPokemonEvolveConditions(s16 index, unkEvolve *r1); u8 GetPokemonOverworldPalette(s16 index, bool32 recolorShopKecleon); -bool8 IsPokemonDialogueSpriteAvail(s16 index, s32 spriteId); OpenedFile *OpenPokemonDialogueSpriteFile(s16 index); OpenedFile *GetDialogueSpriteDataPtr(s32 index); -s32 GetEvolutionSequence(Pokemon *pokemon, EvolveStage *); -s32 sub_808E400(s32 _species, s16* _a2, bool32 _bodySizeCheck, bool32 _shedinjaCheck); -void sub_808E490(Move* a1, s32 species); +bool8 IsPokemonDialogueSpriteAvail(s16 index, s32 spriteId); void RecruitedPokemonToDungeonMon(DungeonMon *dst, u32 recruitedPokemonId); -void PokemonToDungeonMon(DungeonMon *, Pokemon *, s32); +void PokemonToDungeonMon(DungeonMon *dst, Pokemon *src, s32 recruitedPokemonId); void DungeonMonToRecruitedPokemon(s32 id, DungeonMon* src); void DungeonMonToPokemon(Pokemon* dst, DungeonMon* src); -s32 sub_808E218(unkStruct_808E218_arg *, Pokemon *pokemon); -void CreateLevel1Pokemon(Pokemon *pokemon, s16 _species, u8* name, u32 _itemID, const DungeonLocation *location, u16 *moves); -void sub_808D0D8(Pokemon *pokemon); -Pokemon *TryAddLevel1PokemonToRecruited(s32 species, u8 *name, u32 _itemID, const DungeonLocation *location, u16 *moveID); -Pokemon *GetPlayerPokemonStruct(void); -Pokemon *TryAddPokemonToRecruited(Pokemon*); -Pokemon *sub_808D378(void); -Pokemon *sub_808D3BC(void); -Pokemon *sub_808D3F8(void); -Pokemon *GetRecruitedMonBySpecies(s16 species_, s32 sameSpeciesCounter); -s32 GetFriendSum_808D480(void); -bool8 sub_808D4B0(void); -bool8 sub_808D500(void); -s32 GetUnitSum_808D544(s32 *); -s32 sub_808D580(s32 *); -bool8 ComparePokemonNames(s16, s16); -void PrintPokeNameToBuffer(u8 *buffer, Pokemon *pokemon); +void sub_808DFDC(s32 a1, DungeonMon* a2); void GetLvlUpEntry(LevelData* a1, s32 _id, s32 level); const u8* DecompressMoveID(const u8* a1, u16* moveID); -bool8 sub_808DA44(s32, u32); -void ConvertStoryMonToPokemon(Pokemon *dst, const struct StoryMonData *src); -void sub_808CE74(s16 _species, bool32 _isLeader, u8* name); -Pokemon *sub_808D278(s32 species); +s32 GetMovesLearnedAtLevel(u16* dst, s16 species, s32 level, s32 IQPoints); +bool8 CanMonLearnMove(u16 moveID, s16 _species); +s32 sub_808E218(unkStruct_808E218_arg* a1, Pokemon* pokemon); +s32 GetEvolutionSequence(Pokemon* pokemon, EvolveStage* a2); +s32 sub_808E400(s32 _species, s16* _a2, bool32 _bodySizeCheck, bool32 _shedinjaCheck); +void sub_808E490(Move* a1, s32 species); +char* sub_808E4FC(s32 a1); +char* sub_808E51C(s32 a1); +void InitShadowSprites(s32 param_1, s32 param_2); +bool8 AddShadowSprite(s32 species_, DungeonPos *shadowPos, axdata *axData); static inline bool8 PokemonExists(Pokemon *mon) { diff --git a/src/dungeon_leveling.c b/src/dungeon_leveling.c index 7045d2afc..6c6d3092c 100644 --- a/src/dungeon_leveling.c +++ b/src/dungeon_leveling.c @@ -34,8 +34,6 @@ static EWRAM_DATA s32 sNewDefStats[2] = {0, 0}; void sub_8042A44(Entity *r0); -extern s32 GetMovesLearnedAtLevel(u16* dst, s16 species, s32 level, s32 IQPoints); - 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_menu_team.c b/src/dungeon_menu_team.c index 9115126c1..f29f541fd 100644 --- a/src/dungeon_menu_team.c +++ b/src/dungeon_menu_team.c @@ -46,9 +46,6 @@ #include "text_2.h" #include "weather.h" -extern char* sub_808E4FC(s32 a1); -extern char* sub_808E51C(s32 a1); - EWRAM_DATA s32 gTeamMenuChosenId = 0; static UNUSED EWRAM_DATA u8 sUnused[4] = {0}; EWRAM_DATA static SpriteOAM sOAMStatusDescriptionArrow = {0}; diff --git a/src/dungeon_misc.c b/src/dungeon_misc.c index e05eb7600..f50dd31dd 100644 --- a/src/dungeon_misc.c +++ b/src/dungeon_misc.c @@ -55,7 +55,6 @@ static void EnsureDeoxysLoaded(void); extern bool8 sub_806A58C(s16 r0); extern void sub_8078084(Entity * pokemon); -extern void sub_808DFDC(s32 a1, DungeonMon* a2); extern void sub_8067A80(u8 a0, s32 a1, s32 a2, Pokemon **a3); extern bool8 sub_8070F80(Entity * pokemon, s32 direction); extern s32 sub_806A4DC(EntityInfo *info); diff --git a/src/friend_area_action_menu.c b/src/friend_area_action_menu.c index c6c9ebd5e..560418b15 100644 --- a/src/friend_area_action_menu.c +++ b/src/friend_area_action_menu.c @@ -50,8 +50,6 @@ bool8 sub_8027D9C(Pokemon *pokeStruct); extern u8 sub_8027DCC(Pokemon *); extern void SetFriendAreaActionMenuState(u32); extern void PlaySound(u32); -extern void sub_808D31C(Pokemon *); -extern bool8 sub_808D750(s16 index_); u32 sub_8027E18(Pokemon *); u8 sub_8027E4C(Pokemon *r0); diff --git a/src/friend_list.c b/src/friend_list.c index 3e6e958ff..4dc1ccd3d 100644 --- a/src/friend_list.c +++ b/src/friend_list.c @@ -17,8 +17,6 @@ #include "ground_map.h" #include "constants/input.h" -extern bool8 sub_808D750(s32 index_); - static IWRAM_INIT struct unkStruct_3001B60 *sFriendList = {NULL}; static void SortbyAlphabetNo(s32, s32); diff --git a/src/ground_lives.c b/src/ground_lives.c index aa988ff48..2858fa264 100644 --- a/src/ground_lives.c +++ b/src/ground_lives.c @@ -130,8 +130,6 @@ extern bool8 GroundScriptNotify(Action *param_1, s32 param_2); extern bool8 GroundScript_Cancel(Action *r0); extern Pokemon *sub_80A8D54(s32); extern void sub_80A6688(struct UnkGroundSpriteStruct *ptr, s32 a0); -extern s32 sub_808D6A4(s32 *ptr); -extern s32 sub_808D654(s32 *ptr); extern bool8 GetCurrentDungeonBounds(PixelPos *a0, PixelPos *a1); extern void sub_80A7428(struct UnkGroundSpriteStruct *ptr, s32 a1_, s32 monsterId_, s32 a3); extern void SetPredefinedScript(Action *param_1, s16 index, const ScriptCommand *param_3); diff --git a/src/ground_sprite.c b/src/ground_sprite.c index 265ede12c..399829cde 100644 --- a/src/ground_sprite.c +++ b/src/ground_sprite.c @@ -11,6 +11,7 @@ #include "memory.h" #include "sprite.h" #include "effect_sub_1.h" +#include "pokemon.h" static IWRAM_INIT unkStruct_3001B7C *gUnknown_3001B7C = {NULL}; @@ -28,9 +29,6 @@ static EWRAM_INIT OpenedFile *gUnknown_203B4B4 = {NULL}; // code_8098BDC.s extern void sub_809971C(u16, const u8 *, s16); extern void sub_80997F4(u16, u16); -// pokemon_2.s -extern void InitShadowSprites(u32, u32); - extern void sub_80ABA7C(void); extern void sub_80ACAD4(void); extern void sub_80AD7AC(void); diff --git a/src/ground_sprite_monster.c b/src/ground_sprite_monster.c index 4b5824a0b..149f30c73 100644 --- a/src/ground_sprite_monster.c +++ b/src/ground_sprite_monster.c @@ -7,7 +7,6 @@ #include "pokemon.h" extern s32 sub_800E700(s32); -extern bool8 AddShadowSprite(s32 species, DungeonPos* a2, axdata* a3); void sub_80A7428(struct UnkGroundSpriteStruct *ptr, s32 a1_, s32 monsterId_, s32 a3) { diff --git a/src/party_list_menu.c b/src/party_list_menu.c index 3992382ad..1a26d31e3 100644 --- a/src/party_list_menu.c +++ b/src/party_list_menu.c @@ -34,14 +34,12 @@ static EWRAM_INIT unkStruct_203B2B8 *sUnknown_203B2B8 = {NULL}; extern u32 sub_8026F04(Pokemon *); bool8 CanTakePokemonHeldItem(Pokemon *r0); -extern bool8 sub_808D750(s16 index_); bool8 sub_8026E88(Pokemon *r0); bool8 sub_8026EB8(Pokemon *r0); void sub_8026E08(u32 r0); void sub_8026DAC(u32 r0, BulkItem *item); void sub_8026FA4(void); void PartyListMenu_BuildYesNoMenu(void); -extern void sub_808D31C(Pokemon *); void PartyListMenu_CreateMenu2(void); void PartyListMenu_CreateMenu1(void); diff --git a/src/pokemon.c b/src/pokemon.c index a3183bad8..ffd9e97d5 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -514,7 +514,7 @@ s32 sub_808D6A4(s32 *ptr) return count; } -bool8 sub_808D6E8() +UNUSED static bool8 sub_808D6E8(void) { s32 i; s32 count = 0; @@ -532,48 +532,51 @@ bool8 sub_808D6E8() return 0; } - bool8 sub_808D750(s32 index_) - { - Pokemon* pokemon; - s32 i; - s32 index = (s16) index_; - s32 count = 0; - s32 size_count = 0; +bool8 sub_808D750(s32 index_) +{ + Pokemon* pokemon; + s32 i; + s32 index = (s16) index_; + s32 count = 0; + s32 size_count = 0; - for (i = 0; i < NUM_MONSTERS; i++) { - pokemon = &gRecruitedPokemonRef->pokemon[i]; - if (PokemonExists(pokemon) && PokemonFlag2(pokemon)) { - size_count += GetBodySize(pokemon->speciesNum); - count++; - } - } - - if (count < 4) { - pokemon = &gRecruitedPokemonRef->pokemon[index]; + for (i = 0; i < NUM_MONSTERS; i++) { + pokemon = &gRecruitedPokemonRef->pokemon[i]; + if (PokemonExists(pokemon) && PokemonFlag2(pokemon)) { size_count += GetBodySize(pokemon->speciesNum); - if (size_count < 7) { - return TRUE; - } + count++; } - - return FALSE; } -void PeekPokemonItem(s16 index_, BulkItem* item) { + if (count < 4) { + pokemon = &gRecruitedPokemonRef->pokemon[index]; + size_count += GetBodySize(pokemon->speciesNum); + if (size_count < 7) { + return TRUE; + } + } + + return FALSE; +} + +void PeekPokemonItem(s16 index_, BulkItem* item) +{ s32 index = index_; Pokemon* pokemon = &gRecruitedPokemonRef->pokemon[index]; item->id = pokemon->heldItem.id; item->quantity = pokemon->heldItem.quantity; } -void GivePokemonItem(s16 index_, BulkItem* item) { +void GivePokemonItem(s16 index_, BulkItem* item) +{ s32 index = index_; Pokemon* pokemon = &gRecruitedPokemonRef->pokemon[index]; pokemon->heldItem.id = item->id; pokemon->heldItem.quantity = item->quantity; } -bool8 IsPokemonRenamed(Pokemon* pokemon) { +bool8 IsPokemonRenamed(Pokemon* pokemon) +{ char species_name[20]; char* species = GetMonSpecies(pokemon->speciesNum); s32 i; @@ -834,7 +837,6 @@ s16 GetAlphabetParentNo(s16 index, s32 r1) return sMonsterParameters[index].alphabetParent[r1]; } - s16 GetInternalNo(s16 index) { return sMonsterParameters[index].dexInternal[1]; @@ -1117,7 +1119,6 @@ bool8 CanMonLearnMove(u16 moveID, s16 _species) return FALSE; } - s32 sub_808E218(unkStruct_808E218_arg* a1, Pokemon* pokemon) { s32 i; @@ -1177,7 +1178,7 @@ s32 sub_808E218(unkStruct_808E218_arg* a1, Pokemon* pokemon) return count; } -s32 GetEvolutionSequence(Pokemon* pokemon, struct EvolveStage* a2) +s32 GetEvolutionSequence(Pokemon* pokemon, EvolveStage* a2) { s32 count; s32 species; @@ -1338,17 +1339,18 @@ void InitShadowSprites(s32 param_1, s32 param_2) } } -static const s32 gUnknown_81076C4[6] = {-4, -8, -16, -4, -8, -16}; // x-coord positioning for shadow sprites +static const s32 sShadowXPosOffsets[6] = {-4, -8, -16, -4, -8, -16}; -bool8 AddShadowSprite(s16 species, s16* a2, s16* a3) +bool8 AddShadowSprite(s32 species_, DungeonPos *shadowPos, axdata *axData) { + s16 species = (s16) (species_); if (species != MONSTER_DIGLETT && species != MONSTER_DUGTRIO) { s32 shadowSize = GetShadowSize(species); s32 x, y; - x = a2[0] + a3[8]; - y = a2[1] + a3[9]; - x += gUnknown_81076C4[shadowSize]; + x = shadowPos->x + axData->sub1.shadow.x; + y = shadowPos->y + axData->sub1.shadow.y; + x += sShadowXPosOffsets[shadowSize]; y -= 4; SpriteSetX(&sShadowSprites[shadowSize], x); diff --git a/src/run_dungeon.c b/src/run_dungeon.c index 4c202b33c..2fd2024f1 100644 --- a/src/run_dungeon.c +++ b/src/run_dungeon.c @@ -86,7 +86,6 @@ extern void sub_8068F80(void); extern void sub_8042E98(void); extern bool8 TryForcedLoss(bool8); extern void sub_806A914(bool8 a0, bool8 a1, bool8 showRunAwayEffect); -extern s32 GetMovesLearnedAtLevel(u16* dst, s16 species, s32 level, s32 IQPoints); extern void sub_8042B0C(Entity *); extern u8 gUnknown_202F32C;