From c04159817d284d92664fcfbf989273b27a85f5bb Mon Sep 17 00:00:00 2001 From: Kermalis <29823718+Kermalis@users.noreply.github.com> Date: Fri, 1 Sep 2023 04:09:46 -0400 Subject: [PATCH] Clean moves.c --- include/code_809447C.h | 1 + include/moves.h | 142 +++-- include/pokemon.h | 7 +- src/code_801AFA4.c | 21 +- src/code_801EE10_mid.c | 1 - src/code_8057824.c | 10 - src/code_805A120.c | 9 - src/code_8077274_1.c | 1 + src/code_809447C.c | 1 - src/code_8094F88.c | 3 +- src/dungeon_ai_attack.c | 2 +- src/move_util.c | 4 +- src/moves.c | 1316 +++++++++++++++++++-------------------- src/party_list_menu.c | 27 +- src/pokemon_3.c | 6 +- src/pokemon_mid.c | 31 +- src/status_checks_1.c | 1 + sym_ewram.txt | 10 +- 18 files changed, 783 insertions(+), 810 deletions(-) diff --git a/include/code_809447C.h b/include/code_809447C.h index 81e572368..cfd1c94d5 100644 --- a/include/code_809447C.h +++ b/include/code_809447C.h @@ -1,6 +1,7 @@ #ifndef GUARD_CODE_809447C_H #define GUARD_CODE_809447C_H +// size: 0xC struct unkStruct_80928C0 { u32 unk0; diff --git a/include/moves.h b/include/moves.h index 5aed2b35d..44046b4a3 100644 --- a/include/moves.h +++ b/include/moves.h @@ -1,70 +1,92 @@ #ifndef GUARD_MOVES_H #define GUARD_MOVES_H +#include "code_809447C.h" #include "constants/move.h" #include "constants/move_id.h" +#include "pokemon.h" +#include "subStruct_203B240.h" +// size: 0x8 +struct MoveLearnset +{ + const u8 *levelUpMoves; + const u8 *HMTMMoves; +}; + +// size: 0x8 +struct MoveDataFile +{ + struct MoveDataEntry *moveData; + struct MoveLearnset *moveLearnsets; +}; + +bool8 CanBeSnatched(u16); +void CopyAndResetMoves(struct Move *, struct Move *); +void CopyBareMoveData(struct Move *, struct Move *); +bool8 DoesMoveCharge(u16); +bool8 FailsWhileMuzzled(u16); +const u8 *GetHMTMMoves(s16); +const u8 *GetLevelUpMoves(s16); +s32 GetLinkedSequence(s32, struct Move *, u16 *); +s32 GetMoveAccuracyOrAIChance(struct Move *, u32); +u8 GetMoveAIWeight(struct Move *); +s32 GetMoveBasePower(struct Move *); +u32 GetMoveBasePP(struct Move *); +u32 GetMoveCritChance(struct Move *); +u32 GetMoveMaxUpgradeLevel(struct Move *); +u32 GetMoveNumberOfChainedHits(struct Move *); +s16 GetMoveTargetAndRange(struct Move *, bool32); +u8 *GetMoveUseText(u16); +u8 GetMoveType(struct Move *); +void InitPokemonMove(struct Move *, u16); +void InitZeroedPPPokemonMove(struct Move *, u16); +bool8 IsAnyMoveLinked(s32, struct Move *); +bool8 IsMoveEnabled(s32, struct Move *); +bool8 IsMoveSet(s32, struct Move *); +bool8 IsNextMoveLinked(s32, struct Move *); +bool8 IsReflectedByMagicCoat(u16); +bool8 IsSoundMove(struct Move *); void LoadWazaParameters(void); -u8 sub_809287C(struct Move *move); -void InitPokemonMove(struct Move *move, u16 moveID); -void sub_8092AA8(struct Move *move, u16 moveID); -void InitZeroedPPPokemonMove(struct Move *move, u16 moveID); -s16 GetMoveTargetAndRange(struct Move *move, u32 isAI); -u8 GetMoveType(struct Move *move); -u8* GetLevelUpMoves(s16 species); -u8* GetHMTMMoves(s16 species); -u8 GetMoveAIWeight(struct Move *move); -u32 GetMoveNumberOfChainedHits(struct Move *move); -s32 GetMoveBasePower(struct Move *move); -s32 GetMoveAccuracyOrAIChance(struct Move *move, u32 accuracyType); -u32 GetMoveBasePP(struct Move *move); -u32 GetMoveMaxUpgradeLevel(struct Move *move); -u32 GetMoveCritChance(struct Move *move); -bool8 MoveCannotHitFrozen(struct Move *move); -bool8 MovesIgnoresTaunted(struct Move *move); -u32 GetMoveRangeID(struct Move *move); -void sub_8092C84(u8 *buffer, u16 moveID); -u8 *GetMoveUseText(u16 moveID); -bool8 IsReflectedByMagicCoat(u16 moveID); -bool8 CanBeSnatched(u16 moveID); -bool8 FailsWhileMuzzled(u16 moveID); -bool8 IsSoundMove(struct Move *move); -bool8 DoesMoveCharge(u16 move); +bool8 MoveCannotHitFrozen(struct Move *); +bool8 MoveIgnoresTaunted(struct Move *); +void RemoveLinkSequenceFromMoves8(struct Move *, s32); +void RestorePokemonMoves(struct unkStruct_8094924 *, struct Move *); +void SavePokemonMoves(struct unkStruct_8094924 *, struct Move *); +bool8 ToggleMoveEnabled(s32, struct Move *); +bool8 ToggleSetMove(s32, struct Move *); +bool8 TryLinkMovesAfter(s32, struct Move *); +void unk_CopyMoves4To8(struct Move *, struct Move *); +void unk_CopyMoves4To8AndClearFlag2Unk4(struct Move *, struct Move *); +s32 unk_FindMoveEnabledForAIAfter4(struct Move *, s32); +s32 unk_FindMoveEnabledForAIAfter8(struct Move *, s32); +s32 unk_FindMoveEnabledForAIAfter8_v2(struct Move *, s32); +s32 unk_FindMoveEnabledForAIBefore8(struct Move *, s32); +s32 unk_FindMoveEnabledForAIBefore8_v2(struct Move *, s32); +void unk_FixLinkedMovesSetEnabled4(struct Move *); +void unk_FixLinkedMovesSetEnabled8(struct Move *); +void unk_FixLinkedMovesSetEnabled8_v2(struct Move *); +s32 unk_MoveIDPrintMoveDescription(s32, u16, s32, struct subStruct_203B240 **); +s32 unk_PrintMoveDescription(s32, struct Move *, s32, struct subStruct_203B240 **); +s32 unk_SetMoveToFirstInLinkedSequence4(struct Move *, s32); +s32 unk_SetMoveToFirstInLinkedSequence8_v2(struct Move *, s32); +s32 unk_SetMoveToLastInLinkedSequence4(struct Move *, s32); +s32 unk_SetMoveToLastInLinkedSequence8_v2(struct Move *, s32); +bool8 UnlinkMovesAfter(s32, struct Move *); +void UnSetMove(s32, struct Move *); -bool8 IsAnyMoveLinked(int unused, struct Move* moves); -bool8 IsNextMoveLinked(int index, struct Move* moves); -void RemoveLinkSequenceFromMoves8(struct Move* moves, int index); -int GetLinkedSequence(int index, struct Move* moves, u16* sequenceMoveIDs); -void unk_CopyMoves4To8(struct Move* destMoves, struct Move* srcMoves); -void sub_8094060(struct Move* srcMoves, struct Move* destMoves); - -void unk_FixLinkedMovesSetEnabled8_v2(struct Move* move); - -void sub_8092D54(u8 *buffer, struct Move *move); -extern void CopyAndResetMove(struct Move *, struct Move *); - -void unk_GetLinkedSequences4(struct Move* moves, struct Move linkedSequences[4][4]); -void unk_LinkedSequencesToMoves4(struct Move* moves, struct Move linkedSequences[4][4]); -void unk_GetLinkedSequences8(struct Move* moves, struct Move linkedSequences[8][8]); -void unk_LinkedSequencesToMoves8(struct Move* moves, struct Move linkedSequences[8][8]); -void unk_GetLinkedSequences8_v2(struct Move* moves, struct Move linkedSequences[8][8]); -void unk_LinkedSequencesToMoves8_v2(struct Move* moves, struct Move linkedSequences[8][8]); - -int unk_FindMarkedMoveInLinkedSequences44(struct Move linkedSequences[4][4]); -void unk_LinkedSequencesToMoves4(struct Move* moves, struct Move linkedSequences[4][4]); -int unk_FindMarkedMoveInLinkedSequences88(struct Move linkedSequences[8][8]); -void unk_LinkedSequencesToMoves8(struct Move* moves, struct Move linkedSequences[8][8]); -int unk_FindMarkedMoveInLinkedSequences88_v2(struct Move linkedSequences[8][8]); -void unk_LinkedSequencesToMoves8_v2(struct Move* moves, struct Move linkedSequences[8][8]); - -bool8 IsMoveSet(int index, struct Move* struct_ptr); -bool8 IsMoveEnabled(int index, struct Move* struct_ptr); -bool8 TryLinkMovesAfter(int index, struct Move* moves); -bool8 UnlinkMovesAfter(int index, struct Move* moves); -bool8 ToggleSetMove(int index, struct Move* moves); -void UnSetMove(int index, struct Move* moves); -bool8 ToggleMoveEnabled(int index, struct Move* moves); -bool8 sub_8093318(int param_1, void* src_struct); -bool8 sub_809333C(int param_1, void* src_struct); +u8 sub_809287C(struct Move *); +void sub_80928A0(u8 *, struct Move *, const struct unkStruct_80928C0 *); +void sub_80928C0(u8 *, struct Move *, const struct unkStruct_80928C0 *); +void sub_8092AA8(struct Move *, u16); +void sub_8092C84(u8 *, u16); +s32 sub_8092DB8(struct Move *, s32); +s32 sub_8092F4C(struct Move *, s32); +bool8 sub_8093318(s32, struct Move *); +bool8 sub_809333C(s32, struct Move *); +s32 sub_80935B8(struct Move *, s32); +void sub_8094060(struct Move *, struct Move *); +void sub_8094184(struct unkStruct_8094924 *, struct unkStruct_8094184 *); +void sub_80941FC(struct unkStruct_8094924 *, struct unkStruct_8094184 *); #endif // GUARD_MOVES_H diff --git a/include/pokemon.h b/include/pokemon.h index 2ed0a6f1c..5bd6d012a 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -193,10 +193,14 @@ void LoadMonsterParameters(void); struct unkStruct_203B45C *GetRecruitedPokemon(void); void InitializeRecruitedPokemon(void); +// These two need to be overridden in status_actions.c +// Uncomment when fixed +//void CopyCyanMonsterNametoBuffer(u8 *buffer, s16 index); +//u8 GetBodySize(s16 index); + void CopyMonsterNametoBuffer(u8 * buffer, s16 index); void CopyYellowMonsterNametoBuffer(u8 *buffer, s16 index); -void CopyCyanMonsterNametoBuffer(u8 *buffer, s16 index); void PrintColoredPokeNameToBuffer(u8 *buffer, struct PokemonStruct *pokemon, s32 colorNum); void sub_808D930(u8 *buffer, s32 index); void sub_808D9DC(u8 *buffer, struct PokemonStruct2 *param_2, s32 colorNum); @@ -207,7 +211,6 @@ bool8 IsPokemonRenamed(struct PokemonStruct* pokemon); bool8 CanMonLearnMove(u16 moveID, s16 _species); u8 *GetCategoryString(s16 index); -u8 GetBodySize(s16 index); u8 GetShadowSize(s16 index); char * GetMonSpecies(s16 index); s32 GetMovementSpeed(s16 index); diff --git a/src/code_801AFA4.c b/src/code_801AFA4.c index 9cf65cf05..c1996b045 100644 --- a/src/code_801AFA4.c +++ b/src/code_801AFA4.c @@ -1,15 +1,15 @@ #include "global.h" -#include "memory.h" -#include "text.h" -#include "item.h" -#include "team_inventory.h" -#include "menu.h" -#include "pokemon.h" -#include "gulpin_shop.h" -#include "code_80130A8.h" #include "code_80118A4.h" +#include "code_80130A8.h" +#include "gulpin_shop.h" +#include "item.h" +#include "memory.h" +#include "menu.h" +#include "moves.h" +#include "pokemon.h" +#include "team_inventory.h" +#include "text.h" -extern void sub_8092C84(u8 *, u16); extern void sub_8099690(u32); extern s32 GetNumMonsAbleToLearnItemMove(void); extern void sub_801B064(s32); @@ -29,11 +29,8 @@ extern u8 gUnknown_202E1C8[0x50]; extern u8 gAvailablePokemonNames[0x50]; extern u8 gUnknown_202E218[0x50]; -extern void InitZeroedPPPokemonMove(struct Move*, u16); -extern void unk_CopyMoves4To8(struct Move *, struct Move *); extern bool8 IsHMItem(u8); extern void sub_801B178(void); -extern void sub_8094060(void *, struct Move *); extern void PrintPokeNameToBuffer(u8 *buffer, struct PokemonStruct *pokemon); extern u32 sub_801E8C0(void); diff --git a/src/code_801EE10_mid.c b/src/code_801EE10_mid.c index 63acaf90c..868a4c071 100644 --- a/src/code_801EE10_mid.c +++ b/src/code_801EE10_mid.c @@ -63,7 +63,6 @@ extern void sub_801FA58(void); extern void sub_801FAD4(void); extern void sub_801F930(void); extern void sub_801F9A4(void); -int unk_MoveIDPrintMoveDescription(int a1, u16 moveID, int a3, struct subStruct_203B240** a4); void sub_8013F84(void); diff --git a/src/code_8057824.c b/src/code_8057824.c index 3db250129..4aea0d7f8 100644 --- a/src/code_8057824.c +++ b/src/code_8057824.c @@ -105,16 +105,6 @@ extern u32 gUnknown_202F21C; extern bool8 gUnknown_202F220; extern u32 gUnknown_8106A54[]; -struct unkStruct_80928C0 -{ - u32 unk0; - s32 unk4; - u8 unk8; - u8 unk9; -}; - -void sub_80928C0(u8 *buffer, struct Move *move, struct unkStruct_80928C0 *param_3); - extern void sub_806ABAC(struct Entity *, struct Entity *); extern u8 sub_806F4A4(struct Entity *, u32); extern void sub_807DF38(struct Entity *pokemon, struct Entity *target, struct Position *pos, u32, u8 moveType, s16); diff --git a/src/code_805A120.c b/src/code_805A120.c index 41675d41b..9183b6995 100644 --- a/src/code_805A120.c +++ b/src/code_805A120.c @@ -128,15 +128,6 @@ extern u8 *gUnknown_80FE330[]; extern u8 *gUnknown_80FE36C[]; extern u8 *gPtrForecastPreventsTypeSwitchMessage[]; -struct unkStruct_80928C0 -{ - u32 unk0; - s32 unk4; - u8 unk8; - u8 unk9; -}; - -void sub_80928C0(u8 *buffer, struct Move *move, struct unkStruct_80928C0 *param_3); extern u8 sub_806F4A4(struct Entity *, u32); extern void sub_807DF38(struct Entity *pokemon, struct Entity *target, struct Position *pos, u32, u8 moveType, s16); diff --git a/src/code_8077274_1.c b/src/code_8077274_1.c index 68a903f89..16fa3de00 100644 --- a/src/code_8077274_1.c +++ b/src/code_8077274_1.c @@ -211,6 +211,7 @@ extern void sub_8041DD8(struct Entity *r0, s32 r1); // NOTE: is s16 in another f extern s32 sub_803D870(void *, u32); extern bool8 sub_806AA0C(s32, u32); u32 ExtractSpeciesIndex(struct PokemonStruct **r0); // TODO: look more into this and fix it. +void CopyCyanMonsterNametoBuffer(u8 *buffer, s16 index); void MuzzleTarget(struct Entity *pokemon, struct Entity *target) { diff --git a/src/code_809447C.c b/src/code_809447C.c index 77b3fefb1..bda829b32 100644 --- a/src/code_809447C.c +++ b/src/code_809447C.c @@ -38,7 +38,6 @@ extern u8 *gUnknown_8113870[]; extern struct unkStruct_8113080 gUnknown_8113080[]; -void sub_80928C0(u8 *buffer, struct Move *move, struct unkStruct_80928C0 *param_3); extern void xxx_format_string(const char *, u8 *, void *, u32); void PrintYellowDungeonNametoBuffer(u8 *buffer, struct DungeonLocation *dungeonLocation); extern s32 sub_8008ED0(u8 *); diff --git a/src/code_8094F88.c b/src/code_8094F88.c index 7bd7d4e1a..d6a502414 100644 --- a/src/code_8094F88.c +++ b/src/code_8094F88.c @@ -2,6 +2,7 @@ #include "code_8094F88.h" #include "constants/wonder_mail.h" #include "memory.h" +#include "moves.h" #include "dungeon.h" #include "random.h" #include "save.h" @@ -22,8 +23,6 @@ extern void SaveDungeonLocation(struct unkStruct_8094924*, struct DungeonLocatio extern void RestoreDungeonLocation(struct unkStruct_8094924*, struct DungeonLocation*); extern void xxx_save_poke_sub_c_808F41C(struct unkStruct_8094924* a1, struct unkPokeSubStruct_C* unkC); extern void xxx_restore_poke_sub_c_808F410(struct unkStruct_8094924*, struct unkPokeSubStruct_C*); -extern void SavePokemonMoves(struct unkStruct_8094924 *r0, struct Move *moveSet); -extern void RestorePokemonMoves(struct unkStruct_8094924 *r0, struct Move *moveSet); extern struct PokemonStruct *GetPlayerPokemonStruct(void); extern s32 sub_8094E4C(void); diff --git a/src/dungeon_ai_attack.c b/src/dungeon_ai_attack.c index 465ccc546..45c3720c7 100644 --- a/src/dungeon_ai_attack.c +++ b/src/dungeon_ai_attack.c @@ -354,7 +354,7 @@ s32 AIConsiderMove(struct AIPossibleMove *aiPossibleMove, struct Entity *pokemon targetingFlags = GetMoveTargetAndRangeForPokemon(pokemon, move, TRUE); hasStatusChecker = IQSkillIsEnabled(pokemon, IQ_STATUS_CHECKER); aiPossibleMove->canBeUsed = FALSE; - if ((pokemonInfo->volatileStatus == STATUS_TAUNTED && !MovesIgnoresTaunted(move)) || + if ((pokemonInfo->volatileStatus == STATUS_TAUNTED && !MoveIgnoresTaunted(move)) || (hasStatusChecker && !CanUseOnSelfWithStatusChecker(pokemon, move))) { return 1; diff --git a/src/move_util.c b/src/move_util.c index 6553672ae..d448d7a30 100644 --- a/src/move_util.c +++ b/src/move_util.c @@ -225,7 +225,7 @@ bool8 CanMonsterUseMove(struct Entity *pokemon, struct Move *move, bool8 hasPPCh { return FALSE; } - if (pokemonInfo->volatileStatus == STATUS_TAUNTED && !MovesIgnoresTaunted(move)) + if (pokemonInfo->volatileStatus == STATUS_TAUNTED && !MoveIgnoresTaunted(move)) { return FALSE; } @@ -257,7 +257,7 @@ bool8 sub_805744C(struct Entity * pokemon, struct Move *move, bool8 param_3) return FALSE; } if (param_3 != 0) { - if ((entityInfo->volatileStatus == STATUS_TAUNTED) && (!MovesIgnoresTaunted(move))) return FALSE; + if ((entityInfo->volatileStatus == STATUS_TAUNTED) && (!MoveIgnoresTaunted(move))) return FALSE; if (entityInfo->volatileStatus == STATUS_ENCORE) { if (move->id == MOVE_STRUGGLE) { if((entityInfo->struggleMoveFlags & MOVE_FLAG_LAST_USED) == 0) return FALSE; diff --git a/src/moves.c b/src/moves.c index 01ece9c5a..0ac653a78 100644 --- a/src/moves.c +++ b/src/moves.c @@ -1,158 +1,135 @@ #include "global.h" -#include "moves.h" -#include "code_8092334.h" -#include "memory.h" -#include "pokemon.h" -#include "subStruct_203B240.h" -#include "code_809447C.h" -#include "text_util.h" -#include "text2.h" -#include "constants/colors.h" -#include "constants/monster.h" #include "code_800D090.h" #include "code_80130A8.h" +#include "code_8092334.h" +#include "constants/colors.h" +#include "constants/monster.h" +#include "memory.h" +#include "moves.h" +#include "text_util.h" +#include "text2.h" -struct MoveLearnset { - u8 *levelUpMoves; - u8 *HMTMMoves; -}; +static EWRAM_DATA struct OpenedFile *sWazaParametersFile = {0}; +static EWRAM_DATA struct MoveDataEntry *sMovesData = {0}; +static EWRAM_DATA struct MoveLearnset *sMoveLearnsets = {0}; // 420 entries, aka (MONSTER_DEOXYS_SPEED + 1), aka (MONSTER_MUNCHLAX) -struct MoveDataFile -{ - struct MoveDataEntry *moveData; - struct MoveLearnset *moveLearnsets; -}; - - -extern struct unkStruct_80928C0 gUnknown_81098C4; -extern struct FileArchive gSystemFileArchive; - -extern struct OpenedFile *gWazaParametersFile; -extern struct MoveDataEntry *gMovesData; -extern struct MoveLearnset *gMoveLearnsets[420]; - -extern u8 gUnknown_81098D0[]; -extern u8 gUnknown_81098DC[]; -extern u8 gUnknown_810990C[]; -extern u8 gUnknown_8109908[]; -extern u8 gUnknown_8109928[]; -extern u8 gUnknown_8109910[]; -extern u8 gUnknown_81098E0[]; -extern u8 gUnknown_81098EC[]; -extern u8 *gRangeNames[]; -extern u8 gUnknown_810992C[]; -extern u8 gUnknown_810992B; - -extern void sub_8093F10(struct Move *, struct Move *); -extern void sub_80928C0(u8 *, struct Move *, struct unkStruct_80928C0 *); - -extern u8 gAvailablePokemonNames[]; -extern const char gUnknown_8109930[]; -extern struct MoveDataEntry *gMovesData; - -bool8 UnlinkMovesAfter(int param_1, struct Move* src_struct); -bool8 TryLinkMovesAfter(int param_1, struct Move* src_struct); -bool8 sub_80933D8(int param_1, void* src_struct); -bool8 DoesMoveCharge(u16 move); - -int unk_PrintMoveDescription(int, struct Move*, int, struct subStruct_203B240**); - -void sub_80928C0(u8 *buffer, struct Move *move, struct unkStruct_80928C0 *param_3); -extern void unk_MovePrintData(struct Move*, int); // print something -extern u32 sub_8097DF0(char *, struct subStruct_203B240 **); - -extern u8 sub_8092B00(struct Move*); -extern u32 sub_8092BC0(struct Move*); +// ??? extern u32 gUnknown_202DE30; -extern u8* gPtrTypeText; // "Type" -extern u8* gUnknown_810CF00; // "Range#=@.$m0 " +extern u8 gAvailablePokemonNames[]; // 202DF98 + +// data_8107010.s +extern const struct unkStruct_80928C0 gUnknown_81098C4; +extern const u8 gUnknown_81098D0[]; +extern const u8 gUnknown_81098DC[]; +extern const u8 gUnknown_81098E0[]; +extern const u8 gUnknown_81098EC[]; +extern const u8 gUnknown_8109908[]; +extern const u8 gUnknown_810990C[]; +extern const u8 gUnknown_8109910[]; +extern const u8 gUnknown_8109928[]; +extern const u8 gUnknown_810992B; +extern const u8 gUnknown_810992C[]; +extern const u8 gUnknown_8109930[]; + +// data_810AE24.s +extern const u8* gPtrTypeText; // "Type" +extern const u8 *gRangeNames[]; +extern const u8* gUnknown_810CF00; // "Range#=@.$m0 " + +// system_sbin.s +extern const struct FileArchive gSystemFileArchive; + +// code_8097DD0.s +extern u32 sub_8097DF0(u8 *, struct subStruct_203B240 **); + +static void CopyAndResetMove(struct Move *, struct Move *); +static bool8 sub_80933D8(s32, struct Move *); +static s32 unk_FindMarkedMoveInLinkedSequences44(struct Move [MAX_MON_MOVES][MAX_MON_MOVES]); +static s32 unk_FindMarkedMoveInLinkedSequences88(struct Move [8][8]); +static s32 unk_FindMarkedMoveInLinkedSequences88_v2(struct Move [8][8]); +static void unk_GetLinkedSequences4(struct Move *, struct Move [MAX_MON_MOVES][MAX_MON_MOVES]); +static void unk_GetLinkedSequences8(struct Move *, struct Move [8][8]); +static void unk_GetLinkedSequences8_v2(struct Move *, struct Move [8][8]); +static void unk_LinkedSequencesToMoves4(struct Move *, struct Move [MAX_MON_MOVES][MAX_MON_MOVES]); +static void unk_LinkedSequencesToMoves8(struct Move *, struct Move [8][8]); +static void unk_LinkedSequencesToMoves8_v2(struct Move *, struct Move [8][8]); +static void unk_MovePrintData(struct Move *, s32); void LoadWazaParameters(void) { - gWazaParametersFile = OpenFileAndGetFileDataPtr(gUnknown_81098D0, &gSystemFileArchive); + sWazaParametersFile = OpenFileAndGetFileDataPtr(gUnknown_81098D0, &gSystemFileArchive); - gMovesData = ((struct MoveDataFile *)(gWazaParametersFile->data))->moveData; - *gMoveLearnsets = ((struct MoveDataFile *)(gWazaParametersFile->data))->moveLearnsets; + sMovesData = ((struct MoveDataFile *)(sWazaParametersFile->data))->moveData; + sMoveLearnsets = ((struct MoveDataFile *)(sWazaParametersFile->data))->moveLearnsets; } u8 sub_809287C(struct Move *move) { - if((move->moveFlags & MOVE_FLAG_DISABLED) != 0) - return 0x32; - else if((move->moveFlags2 & MOVE_FLAG_SEALED) == 0) - return 0x34; - else - return 0x32; + if (move->moveFlags & MOVE_FLAG_DISABLED) + return 50; + if (!(move->moveFlags2 & MOVE_FLAG_SEALED)) + return 52; + return 50; } -void sub_80928A0(u8 *buffer, struct Move *move, struct unkStruct_80928C0 *r2) +void sub_80928A0(u8 *buffer, struct Move *move, const struct unkStruct_80928C0 *a2) { struct Move stack; CopyAndResetMove(&stack, move); - sub_80928C0(buffer, &stack, r2); + sub_80928C0(buffer, &stack, a2); } -void sub_80928C0(u8 *buffer, struct Move *move, struct unkStruct_80928C0 *param_3) +void sub_80928C0(u8 *buffer, struct Move *move, const struct unkStruct_80928C0 *param_3) { - u32 uVar2; - u32 basePP; - u8 localBuffer[12]; + u32 uVar2; + u32 basePP; + u8 localBuffer[12]; - uVar2 = sub_809287C(move); - if (param_3 == NULL) { - param_3 = &gUnknown_81098C4; - } + uVar2 = sub_809287C(move); - if (move->ginseng != 0) - sprintfStatic(localBuffer,gUnknown_81098DC,move->ginseng); // %+d - else - localBuffer[0] = '\0'; + if (param_3 == NULL) + param_3 = &gUnknown_81098C4; - if (param_3->unk8 != 0) { + if (move->ginseng != 0) + sprintfStatic(localBuffer, gUnknown_81098DC, move->ginseng); // %+d + else + localBuffer[0] = '\0'; + + if (param_3->unk8 != 0) uVar2 = 2; - } - if (param_3->unk9 != 0 && DoesMoveCharge(move->id)) { + if (param_3->unk9 != 0 && DoesMoveCharge(move->id)) uVar2 = 2; - } - switch(param_3->unk0) { + + switch (param_3->unk0) { case 0: - sprintfStatic - (buffer,gUnknown_81098E0,uVar2, - gMovesData[move->id].name,localBuffer); + sprintfStatic(buffer, gUnknown_81098E0, + uVar2, sMovesData[move->id].name, localBuffer); break; - case 1: basePP = GetMoveBasePP(move); - sprintfStatic - (buffer,gUnknown_81098EC,uVar2,move->moveFlags & MOVE_FLAG_SET ? gUnknown_8109908 : gUnknown_810990C, - gMovesData[move->id].name,localBuffer,param_3->unk4, - move->PP,basePP); + sprintfStatic(buffer, gUnknown_81098EC, + uVar2, move->moveFlags & MOVE_FLAG_SET ? gUnknown_8109908 : gUnknown_810990C, + sMovesData[move->id].name, localBuffer, param_3->unk4, move->PP, basePP); break; - case 2: basePP = GetMoveBasePP(move); - sprintfStatic - (buffer,gUnknown_8109910,uVar2,move->moveFlags & MOVE_FLAG_SET ? gUnknown_8109908 : gUnknown_810990C, - gMovesData[move->id].name,localBuffer,param_3->unk4, - move->PP,basePP); + sprintfStatic(buffer, gUnknown_8109910, + uVar2, move->moveFlags & MOVE_FLAG_SET ? gUnknown_8109908 : gUnknown_810990C, + sMovesData[move->id].name, localBuffer, param_3->unk4, move->PP, basePP); break; - case 3: basePP = GetMoveBasePP(move); - sprintfStatic - (buffer,gUnknown_81098EC,uVar2,move->moveFlags & MOVE_FLAG_ENABLED_FOR_AI ? gUnknown_8109928 : gUnknown_810990C, - gMovesData[move->id].name,localBuffer,param_3->unk4, - move->PP,basePP); + sprintfStatic(buffer, gUnknown_81098EC, + uVar2, move->moveFlags & MOVE_FLAG_ENABLED_FOR_AI ? gUnknown_8109928 : gUnknown_810990C, + sMovesData[move->id].name, localBuffer, param_3->unk4, move->PP, basePP); break; - case 4: basePP = GetMoveBasePP(move); - sprintfStatic - (buffer,gUnknown_8109910,uVar2, move->moveFlags & MOVE_FLAG_ENABLED_FOR_AI ? gUnknown_8109928 : gUnknown_810990C, - gMovesData[move->id].name,localBuffer,param_3->unk4, - move->PP,basePP); + sprintfStatic(buffer, gUnknown_8109910, + uVar2, move->moveFlags & MOVE_FLAG_ENABLED_FOR_AI ? gUnknown_8109928 : gUnknown_810990C, + sMovesData[move->id].name, localBuffer, param_3->unk4, move->PP, basePP); break; - } + } } void InitPokemonMove(struct Move *move, u16 moveID) @@ -166,10 +143,9 @@ void InitPokemonMove(struct Move *move, u16 moveID) void sub_8092AA8(struct Move *move, u16 moveID) { - if(moveID == 0) + if (moveID == 0) move->moveFlags = 0; - else - { + else { move->moveFlags = MOVE_FLAG_ENABLED_FOR_AI | MOVE_FLAG_EXISTS; move->moveFlags2 = 0; move->id = moveID; @@ -187,18 +163,16 @@ void InitZeroedPPPokemonMove(struct Move *move, u16 moveID) s16 GetMoveTargetAndRange(struct Move *move, bool32 isAI) { - return gMovesData[move->id].targetingFlags[isAI]; + return sMovesData[move->id].targetingFlags[isAI]; } u8 GetMoveType(struct Move *move) { - return gMovesData[move->id].type; + return sMovesData[move->id].type; } - -u8 *GetLevelUpMoves(s16 species) +const u8 *GetLevelUpMoves(s16 species) { - #ifndef NONMATCHING register s32 species1 asm("r1"), species2; #else @@ -208,19 +182,16 @@ u8 *GetLevelUpMoves(s16 species) species1 = species; species2 = species1; if (species1 == MONSTER_DECOY || species1 == MONSTER_NONE) - { return &gUnknown_810992B; - } + if (species2 == MONSTER_MUNCHLAX) - { return &gUnknown_810992B; - } - return (*gMoveLearnsets)[species2].levelUpMoves; + + return sMoveLearnsets[species2].levelUpMoves; } -u8 *GetHMTMMoves(s16 species) +const u8 *GetHMTMMoves(s16 species) { - #ifndef NONMATCHING register s32 species1 asm("r1"), species2; #else @@ -230,64 +201,62 @@ u8 *GetHMTMMoves(s16 species) species1 = species; species2 = species1; if (species1 == MONSTER_DECOY || species1 == MONSTER_NONE) - { return &gUnknown_810992B; - } + if (species2 == MONSTER_MUNCHLAX) - { return &gUnknown_810992B; - } - return (*gMoveLearnsets)[species2].HMTMMoves; + + return sMoveLearnsets[species2].HMTMMoves; } u8 GetMoveAIWeight(struct Move *move) { - return gMovesData[move->id].aiWeight; + return sMovesData[move->id].aiWeight; } u32 GetMoveNumberOfChainedHits(struct Move *move) { - return gMovesData[move->id].numberOfChainedHits; + return sMovesData[move->id].numberOfChainedHits; } s32 GetMoveBasePower(struct Move *move) { - return gMovesData[move->id].basePower; + return sMovesData[move->id].basePower; } s32 GetMoveAccuracyOrAIChance(struct Move *move, u32 accuracyType) { - return gMovesData[move->id].accuracy[accuracyType]; + return sMovesData[move->id].accuracy[accuracyType]; } u32 GetMoveBasePP(struct Move *move) { - return gMovesData[move->id].basePP; + return sMovesData[move->id].basePP; } u32 GetMoveMaxUpgradeLevel(struct Move *move) { - return gMovesData[move->id].maxUpgradeLevel; + return sMovesData[move->id].maxUpgradeLevel; } u32 GetMoveCritChance(struct Move *move) { - return gMovesData[move->id].critChance; + return sMovesData[move->id].critChance; } bool8 MoveCannotHitFrozen(struct Move *move) { - return gMovesData[move->id].cannotHitFrozen; + return sMovesData[move->id].cannotHitFrozen; } -bool8 MovesIgnoresTaunted(struct Move *move) +bool8 MoveIgnoresTaunted(struct Move *move) { - return gMovesData[move->id].ignoresTaunted; + return sMovesData[move->id].ignoresTaunted; } -u32 GetMoveRangeID(struct Move *move) +static u32 GetMoveRangeID(struct Move *move) { - return gMovesData[move->id].rangeID; + return sMovesData[move->id].rangeID; } void sub_8092C84(u8 *buffer, u16 moveID) @@ -299,78 +268,79 @@ void sub_8092C84(u8 *buffer, u16 moveID) u8 *GetMoveUseText(u16 moveID) { - return gMovesData[moveID].useText; + return sMovesData[moveID].useText; } bool8 IsReflectedByMagicCoat(u16 moveID) { - return gMovesData[moveID].affectedByMagicCoat; + return sMovesData[moveID].affectedByMagicCoat; } bool8 CanBeSnatched(u16 moveID) { - return gMovesData[moveID].isSnatchable; + return sMovesData[moveID].isSnatchable; } bool8 FailsWhileMuzzled(u16 moveID) { - return gMovesData[moveID].usesMouth; + return sMovesData[moveID].usesMouth; } bool8 IsSoundMove(struct Move *move) { - if(move->id == MOVE_GROWL) return TRUE; - if(move->id == MOVE_ROAR) return TRUE; - if(move->id == MOVE_METAL_SOUND) return TRUE; - if(move->id == MOVE_SING) return TRUE; - if(move->id == MOVE_GRASSWHISTLE) return TRUE; - if(move->id == MOVE_SUPERSONIC) return TRUE; - if(move->id == MOVE_PERISH_SONG) return TRUE; - if(move->id == MOVE_SCREECH) return TRUE; - if(move->id == MOVE_HYPER_VOICE) return TRUE; - if(move->id == MOVE_SNORE) return TRUE; - if(move->id == MOVE_HEAL_BELL) return TRUE; + if (move->id == MOVE_GROWL) return TRUE; + if (move->id == MOVE_ROAR) return TRUE; + if (move->id == MOVE_METAL_SOUND) return TRUE; + if (move->id == MOVE_SING) return TRUE; + if (move->id == MOVE_GRASSWHISTLE) return TRUE; + if (move->id == MOVE_SUPERSONIC) return TRUE; + if (move->id == MOVE_PERISH_SONG) return TRUE; + if (move->id == MOVE_SCREECH) return TRUE; + if (move->id == MOVE_HYPER_VOICE) return TRUE; + if (move->id == MOVE_SNORE) return TRUE; + if (move->id == MOVE_HEAL_BELL) return TRUE; return FALSE; } -void sub_8092D54(u8 *buffer, struct Move *move) +static void sub_8092D54(u8 *buffer, struct Move *move) { sprintfStatic(buffer, gUnknown_810992C, gRangeNames[GetMoveRangeID(move)]); } // this function is the same as the two after the next one // except this one is for 4, and the other 2 for 8 and 8_v2 -int unk_FindMoveEnabledForAIAfter4(struct Move* moves, int index) { - int i; - - for (i = 0; i < 4; i++) { +s32 unk_FindMoveEnabledForAIAfter4(struct Move *moves, s32 index) +{ + s32 i; + + for (i = 0; i < MAX_MON_MOVES; i++) { u8 flag; - - if (++index == 4) { + + if (++index == MAX_MON_MOVES) return 0; - } - - if (!(moves[index].moveFlags & MOVE_FLAG_EXISTS)) { + + if (!(moves[index].moveFlags & MOVE_FLAG_EXISTS)) return 0; - } + // checks MOVE_FLAG_ENABLED_FOR_AI flag = (moves[index].moveFlags >> 1); - if (!(flag & 1)) { + if (!(flag & 1)) return index; - } } + return 0; } -int sub_8092DB8(struct Move* moves, int index) { - int i, j; - - for (i = 0; i < 4; i++) { +s32 sub_8092DB8(struct Move *moves, s32 index) +{ + s32 i, j; + + for (i = 0; i < MAX_MON_MOVES; i++) { u8 flag; if (--index < 0) { - for (j = 3; j >= 0; j--) { + for (j = MAX_MON_MOVES - 1; j >= 0; j--) { if (!(moves[j].moveFlags & MOVE_FLAG_EXISTS)) { continue; } @@ -380,166 +350,168 @@ int sub_8092DB8(struct Move* moves, int index) { } // return 0 if loop ends without setting index - if (j < 0) + if (j < 0) return 0; } - - if (!(moves[index].moveFlags & MOVE_FLAG_EXISTS)) { + + if (!(moves[index].moveFlags & MOVE_FLAG_EXISTS)) return 0; - } + // checks MOVE_FLAG_ENABLED_FOR_AI flag = (moves[index].moveFlags >> 1); - if (!(flag & 1)) { + if (!(flag & 1)) return index; - } } + return 0; } -int unk_FindMoveEnabledForAIAfter8(struct Move* moves, int index) { - int i; - +s32 unk_FindMoveEnabledForAIAfter8(struct Move *moves, s32 index) +{ + s32 i; + for (i = 0; i < 8; i++) { u8 flag; - if (++index == 8) { + if (++index == 8) return 0; - } - - if (!(moves[index].moveFlags & 1)) { + + if (!(moves[index].moveFlags & 1)) return 0; - } + // checks MOVE_FLAG_ENABLED_FOR_AI flag = (moves[index].moveFlags >> 1); - if (!(flag & 1)) { + if (!(flag & 1)) return index; - } } + return 0; } -int unk_FindMoveEnabledForAIAfter8_v2(struct Move* moves, int index) { - int i; - +s32 unk_FindMoveEnabledForAIAfter8_v2(struct Move *moves, s32 index) +{ + s32 i; + for (i = 0; i < 8; i++) { u8 flag; - - if (++index == 8) { + + if (++index == 8) return 0; - } - - if (!(moves[index].moveFlags & 1)) { + + if (!(moves[index].moveFlags & 1)) return 0; - } + // checks MOVE_FLAG_ENABLED_FOR_AI flag = (moves[index].moveFlags >> 1); - if (!(flag & 1)) { + if (!(flag & 1)) return index; - } } + return 0; } // the next 2 functions are the same // should be 8 and 8_v2 -int unk_FindMoveEnabledForAIBefore8(struct Move* moves, int index) { - int i, j; - +s32 unk_FindMoveEnabledForAIBefore8(struct Move *moves, s32 index) +{ + s32 i, j; + for (i = 0; i < 8; i++) { u8 flag; - + if (--index < 0) { for (j = 7; j > 0; j--) { - if (!(moves[j].moveFlags & MOVE_FLAG_EXISTS)) { + if (!(moves[j].moveFlags & MOVE_FLAG_EXISTS)) continue; - } - + // checks MOVE_FLAG_ENABLED_FOR_AI flag = (moves[j].moveFlags >> 1); - if (!(flag & 1)) { + if (!(flag & 1)) return j; - } } return 0; } - - if (!(moves[index].moveFlags & MOVE_FLAG_EXISTS)) { + + if (!(moves[index].moveFlags & MOVE_FLAG_EXISTS)) return 0; - } + // checks MOVE_FLAG_ENABLED_FOR_AI flag = (moves[index].moveFlags >> 1); - if (!(flag & 1)) { + if (!(flag & 1)) return index; - } } + return 0; } -int unk_FindMoveEnabledForAIBefore8_v2(struct Move* moves, int index) { - int i, j; - +s32 unk_FindMoveEnabledForAIBefore8_v2(struct Move *moves, s32 index) +{ + s32 i, j; + for (i = 0; i < 8; i++) { u8 flag; - + if (--index < 0) { for (j = 7; j > 0; j--) { - if (!(moves[j].moveFlags & MOVE_FLAG_EXISTS)) { + if (!(moves[j].moveFlags & MOVE_FLAG_EXISTS)) continue; - } - + // checks MOVE_FLAG_ENABLED_FOR_AI flag = (moves[j].moveFlags >> 1); - if (!(flag & 1)) { + if (!(flag & 1)) return j; - } } return 0; } - - if (!(moves[index].moveFlags & MOVE_FLAG_EXISTS)) { + + if (!(moves[index].moveFlags & MOVE_FLAG_EXISTS)) return 0; - } + // checks MOVE_FLAG_ENABLED_FOR_AI flag = (moves[index].moveFlags >> 1); - if (!(flag & 1)) { + if (!(flag & 1)) return index; - } } + return 0; } -int sub_8092F4C(struct Move* moves, int index) { - int i; +s32 sub_8092F4C(struct Move *moves, s32 index) +{ + s32 i; + for (i = index; i > 0; i--) { struct Move* move = &moves[i]; u8 flag; - if (!(move->moveFlags & MOVE_FLAG_EXISTS)) { + + if (!(move->moveFlags & MOVE_FLAG_EXISTS)) return 0; - } + // checks MOVE_FLAG_ENABLED_FOR_AI flag = (move->moveFlags >> 1); - if (!(flag & 1)) { + if (!(flag & 1)) return i; - } } + return 0; } // the next 3 functions are the same, except the first // is for 4, then for 8 then for 8_v2 -int unk_SetMoveToLastInLinkedSequence4(struct Move* moves, int index) { +s32 unk_SetMoveToLastInLinkedSequence4(struct Move *moves, s32 index) +{ struct Move* move; struct Move linkedSequence[4][4]; s32 startIndex; - int result; - int i; - + s32 result; + s32 i; + result = index; - + move = &moves[index]; move->moveFlags |= MOVE_FLAG_INTERNAL_MARKER; unk_GetLinkedSequences4(moves, linkedSequence); - + startIndex = unk_FindMarkedMoveInLinkedSequences44(linkedSequence); if (startIndex >= 0 && startIndex < 3) { for (i = 0; i < 4; i++) { @@ -548,7 +520,7 @@ int unk_SetMoveToLastInLinkedSequence4(struct Move* moves, int index) { linkedSequence[startIndex + 1][i] = temp; } } - + unk_LinkedSequencesToMoves4(moves, linkedSequence); for (startIndex = 0; startIndex < 4; startIndex++) { if (moves[startIndex].moveFlags & MOVE_FLAG_INTERNAL_MARKER) { @@ -557,22 +529,24 @@ int unk_SetMoveToLastInLinkedSequence4(struct Move* moves, int index) { break; } } + return result; } -int unk_SetMoveToLastInLinkedSequence8(struct Move* moves, int index) { +UNUSED static s32 unk_SetMoveToLastInLinkedSequence8(struct Move *moves, s32 index) +{ struct Move* move; struct Move linkedSequence[8][8]; s32 startIndex; - int result; - int i; - + s32 result; + s32 i; + result = index; - + move = &moves[index]; move->moveFlags |= MOVE_FLAG_INTERNAL_MARKER; unk_GetLinkedSequences8(moves, linkedSequence); - + startIndex = unk_FindMarkedMoveInLinkedSequences88(linkedSequence); if (startIndex >= 0 && startIndex < 7) { for (i = 0; i < 8; i++) { @@ -581,7 +555,7 @@ int unk_SetMoveToLastInLinkedSequence8(struct Move* moves, int index) { linkedSequence[startIndex + 1][i] = temp; } } - + unk_LinkedSequencesToMoves8(moves, linkedSequence); for (startIndex = 0; startIndex < 8; startIndex++) { if (moves[startIndex].moveFlags & MOVE_FLAG_INTERNAL_MARKER) { @@ -590,22 +564,24 @@ int unk_SetMoveToLastInLinkedSequence8(struct Move* moves, int index) { break; } } + return result; } -int unk_SetMoveToLastInLinkedSequence8_v2(struct Move* moves, int index) { +s32 unk_SetMoveToLastInLinkedSequence8_v2(struct Move *moves, s32 index) +{ struct Move* move; struct Move linkedSequence[8][8]; s32 startIndex; - int result; - int i; - + s32 result; + s32 i; + result = index; - + move = &moves[index]; move->moveFlags |= MOVE_FLAG_INTERNAL_MARKER; unk_GetLinkedSequences8_v2(moves, linkedSequence); - + startIndex = unk_FindMarkedMoveInLinkedSequences88_v2(linkedSequence); if (startIndex >= 0 && startIndex < 7) { for (i = 0; i < 8; i++) { @@ -614,7 +590,7 @@ int unk_SetMoveToLastInLinkedSequence8_v2(struct Move* moves, int index) { linkedSequence[startIndex + 1][i] = temp; } } - + unk_LinkedSequencesToMoves8_v2(moves, linkedSequence); for (startIndex = 0; startIndex < 8; startIndex++) { if (moves[startIndex].moveFlags & MOVE_FLAG_INTERNAL_MARKER) { @@ -623,24 +599,26 @@ int unk_SetMoveToLastInLinkedSequence8_v2(struct Move* moves, int index) { break; } } + return result; } // the next 3 functions are the same, but for // 4, 8 and 8_v2 -int unk_SetMoveToFirstInLinkedSequence4(struct Move* moves, int index) { +s32 unk_SetMoveToFirstInLinkedSequence4(struct Move *moves, s32 index) +{ struct Move* move; struct Move linkedSequence[4][4]; s32 startIndex, prevIndex; - int result; - int i; - + s32 result; + s32 i; + result = index; - + move = &moves[index]; move->moveFlags |= MOVE_FLAG_INTERNAL_MARKER; unk_GetLinkedSequences4(moves, linkedSequence); - + startIndex = unk_FindMarkedMoveInLinkedSequences44(linkedSequence); prevIndex = startIndex - 1; if (prevIndex >= 0 && prevIndex < 3) { @@ -650,7 +628,7 @@ int unk_SetMoveToFirstInLinkedSequence4(struct Move* moves, int index) { linkedSequence[prevIndex][i] = temp; } } - + unk_LinkedSequencesToMoves4(moves, linkedSequence); for (startIndex = 0; startIndex < 4; startIndex++) { if (moves[startIndex].moveFlags & MOVE_FLAG_INTERNAL_MARKER) { @@ -659,22 +637,24 @@ int unk_SetMoveToFirstInLinkedSequence4(struct Move* moves, int index) { break; } } + return result; } -int unk_SetMoveToFirstInLinkedSequence8(struct Move* moves, int index) { +UNUSED static s32 unk_SetMoveToFirstInLinkedSequence8(struct Move *moves, s32 index) +{ struct Move* move; struct Move linkedSequence[8][8]; s32 startIndex, prevIndex; int result; int i; - + result = index; - + move = &moves[index]; move->moveFlags |= MOVE_FLAG_INTERNAL_MARKER; unk_GetLinkedSequences8(moves, linkedSequence); - + startIndex = unk_FindMarkedMoveInLinkedSequences88(linkedSequence); prevIndex = startIndex - 1; if (prevIndex >= 0 && prevIndex < 7) { @@ -684,7 +664,7 @@ int unk_SetMoveToFirstInLinkedSequence8(struct Move* moves, int index) { linkedSequence[prevIndex][i] = temp; } } - + unk_LinkedSequencesToMoves8(moves, linkedSequence); for (startIndex = 0; startIndex < 8; startIndex++) { if (moves[startIndex].moveFlags & MOVE_FLAG_INTERNAL_MARKER) { @@ -693,22 +673,24 @@ int unk_SetMoveToFirstInLinkedSequence8(struct Move* moves, int index) { break; } } + return result; } -int unk_SetMoveToFirstInLinkedSequence8_v2(struct Move* moves, int index) { +s32 unk_SetMoveToFirstInLinkedSequence8_v2(struct Move *moves, s32 index) +{ struct Move* move; struct Move linkedSequence[8][8]; s32 startIndex, prevIndex; - int result; - int i; - + s32 result; + s32 i; + result = index; - + move = &moves[index]; move->moveFlags |= MOVE_FLAG_INTERNAL_MARKER; unk_GetLinkedSequences8_v2(moves, linkedSequence); - + startIndex = unk_FindMarkedMoveInLinkedSequences88_v2(linkedSequence); prevIndex = startIndex - 1; if (prevIndex >= 0 && prevIndex < 7) { @@ -718,7 +700,7 @@ int unk_SetMoveToFirstInLinkedSequence8_v2(struct Move* moves, int index) { linkedSequence[prevIndex][i] = temp; } } - + unk_LinkedSequencesToMoves8_v2(moves, linkedSequence); for (startIndex = 0; startIndex < 8; startIndex++) { if (moves[startIndex].moveFlags & MOVE_FLAG_INTERNAL_MARKER) { @@ -727,115 +709,112 @@ int unk_SetMoveToFirstInLinkedSequence8_v2(struct Move* moves, int index) { break; } } + return result; } -bool8 IsMoveSet(int index, struct Move* struct_ptr) +bool8 IsMoveSet(s32 index, struct Move *struct_ptr) { - if ((struct_ptr[index].moveFlags & MOVE_FLAG_SET) != 0) { + if (struct_ptr[index].moveFlags & MOVE_FLAG_SET) return TRUE; - } return FALSE; } -bool8 IsMoveEnabled(int index, struct Move* struct_ptr) +bool8 IsMoveEnabled(s32 index, struct Move *struct_ptr) { - if ((struct_ptr[index].moveFlags & MOVE_FLAG_ENABLED_FOR_AI) != 0) { + if (struct_ptr[index].moveFlags & MOVE_FLAG_ENABLED_FOR_AI) return TRUE; - } return FALSE; } -bool8 sub_8093318(int param_1, void* src_struct) +bool8 sub_8093318(s32 param_1, struct Move *src_struct) { - struct Move dest_struct[8]; - MemoryCopy8((void*)dest_struct, src_struct, 64); + struct Move dest_struct[MAX_MON_MOVES * 2]; + MemoryCopy8((void *)dest_struct, (void *)src_struct, sizeof(struct Move) * MAX_MON_MOVES * 2); return TryLinkMovesAfter(param_1, dest_struct); } -bool8 sub_809333C(int param_1, void* src_struct) +bool8 sub_809333C(s32 param_1, struct Move *src_struct) { - struct Move dest_struct[8]; - MemoryCopy8((void*)dest_struct, src_struct, 64); + struct Move dest_struct[MAX_MON_MOVES * 2]; + MemoryCopy8((void *)dest_struct, (void *)src_struct, sizeof(struct Move) * MAX_MON_MOVES * 2); return UnlinkMovesAfter(param_1, dest_struct); } -bool8 sub_8093360(int param_1, void* src_struct) +UNUSED static bool8 sub_8093360(s32 param_1, struct Move *src_struct) { - u8 dest_struct[64]; - MemoryCopy8(dest_struct, src_struct, 64); + struct Move dest_struct[MAX_MON_MOVES * 2]; + MemoryCopy8((void *)dest_struct, (void *)src_struct, sizeof(struct Move) * MAX_MON_MOVES * 2); return sub_80933D8(param_1, dest_struct); } -// appears unused -bool8 IsMoveNotSet(int index, struct Move* struct_ptr) +UNUSED static bool8 IsMoveNotSet(s32 index, struct Move* struct_ptr) { - if ((struct_ptr[index].moveFlags & MOVE_FLAG_SET) != 0) { + if (struct_ptr[index].moveFlags & MOVE_FLAG_SET) return FALSE; - } return TRUE; } -bool8 IsAnyMoveLinked(int unused, struct Move* moves) { - int i; - int counter; +bool8 IsAnyMoveLinked(s32 unused, struct Move *moves) +{ + s32 i; + s32 counter; counter = 0; + for (i = 0; i < 8; i++) { - if ((moves[i].moveFlags & MOVE_FLAG_EXISTS) && !(moves[i].moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN)) { + if ((moves[i].moveFlags & MOVE_FLAG_EXISTS) && !(moves[i].moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN)) counter++; - } } - if (counter > 1) { + + if (counter > 1) return TRUE; - } return FALSE; } -bool8 sub_80933D8(int param_1, void* src_struct) +static bool8 sub_80933D8(s32 param_1, struct Move *src_struct) { - int result; + if (TryLinkMovesAfter(param_1, src_struct)) + return TRUE; - if (!TryLinkMovesAfter(param_1, src_struct)) { - result = UnlinkMovesAfter(param_1, src_struct); - } - else { - result = TRUE; - } - return result; + return UnlinkMovesAfter(param_1, src_struct); } -bool8 TryLinkMovesAfter(int index, struct Move* moves) { - int i; +bool8 TryLinkMovesAfter(s32 index, struct Move *moves) +{ + s32 i; const struct Move *move = &moves[index]; - if (DoesMoveCharge(move->id)) { + + if (DoesMoveCharge(move->id)) return FALSE; - } - + for (i = index + 1; i < 8; i++) { - if (!(moves[i].moveFlags & MOVE_FLAG_EXISTS)) { + if (!(moves[i].moveFlags & MOVE_FLAG_EXISTS)) return FALSE; - } - if (DoesMoveCharge(moves[i].id)) { + + if (DoesMoveCharge(moves[i].id)) return FALSE; - } + if (!(moves[i].moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN)) { moves[i].moveFlags |= MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN; unk_FixLinkedMovesSetEnabled8_v2(moves); return TRUE; } } + return FALSE; } -bool8 UnlinkMovesAfter(int index, struct Move* moves) { - int i; +bool8 UnlinkMovesAfter(s32 index, struct Move *moves) +{ + s32 i; bool8 result = FALSE; - int r4; + s32 r4; for (i = index + 1, r4 = 0; r4 < 8 && i < 8; i++, r4++) { if (!(moves[i].moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN)) goto label; // for some reason we can't use break here + moves[i].moveFlags &= ~MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN; result = TRUE; } @@ -844,163 +823,169 @@ label: return result; } +bool8 IsNextMoveLinked(s32 index, struct Move *moves) +{ + struct Move *move; -bool8 IsNextMoveLinked(int index, struct Move* moves) { - struct Move* move; - if (index + 1 >= 8) { + if (index + 1 >= MAX_MON_MOVES * 2) return FALSE; - } + move = &moves[index + 1]; + if (!(move->moveFlags & MOVE_FLAG_EXISTS)) return FALSE; - if ((move->moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN)) + + if (move->moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN) return TRUE; + return FALSE; } -bool8 ToggleSetMove(int index, struct Move* moves) { +bool8 ToggleSetMove(s32 index, struct Move *moves) +{ struct Move* move; u8 flags; - int i; + s32 i; move = &moves[index]; - if (moves[index].moveFlags & MOVE_FLAG_SET) { + + if (moves[index].moveFlags & MOVE_FLAG_SET) flags = move->moveFlags & ~MOVE_FLAG_SET; - } else { // clear set flag from other moves - for (i = 0; i < 4; i++) { - if (moves[i].moveFlags & MOVE_FLAG_EXISTS) { + for (i = 0; i < MAX_MON_MOVES; i++) { + if (moves[i].moveFlags & MOVE_FLAG_EXISTS) moves[i].moveFlags &= ~MOVE_FLAG_SET; - } } + flags = move->moveFlags | MOVE_FLAG_SET; } + move->moveFlags = flags; unk_FixLinkedMovesSetEnabled8_v2(moves); return TRUE; } -void UnSetMove(int index, struct Move* moves) { +void UnSetMove(s32 index, struct Move *moves) +{ struct Move* move = &moves[index]; move->moveFlags &= ~MOVE_FLAG_SET; unk_FixLinkedMovesSetEnabled8_v2(moves); } -bool8 ToggleMoveEnabled(int index, struct Move* moves) { +bool8 ToggleMoveEnabled(s32 index, struct Move *moves) +{ struct Move* move = &moves[index]; move->moveFlags ^= MOVE_FLAG_ENABLED_FOR_AI; unk_FixLinkedMovesSetEnabled8_v2(moves); return TRUE; } -int GetLinkedSequence(int index, struct Move* moves, u16* sequenceMoveIDs) { - int i; - int linkedSequenceLength; +s32 GetLinkedSequence(s32 index, struct Move *moves, u16 *sequenceMoveIDs) +{ + s32 i; + s32 linkedSequenceLength; struct Move* move; linkedSequenceLength = 1; move = &moves[index]; sequenceMoveIDs[0] = move->id; - for (i = 1; i < 4; i++) { + + for (i = 1; i < 4; i++) sequenceMoveIDs[i] = 0; - } for (index++, sequenceMoveIDs++; index < 8 && linkedSequenceLength <= 3; index++) { move = &moves[index]; - if ((move->moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN) == 0) { + if (!(move->moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN)) return linkedSequenceLength; - } *sequenceMoveIDs++ = move->id; linkedSequenceLength++; } + return linkedSequenceLength; } -int sub_80935B8(struct Move *moves, int index) { - int i; - int linkSequenceStart; - int isNonTrivialLinkSequence; - int any_move_linked; - int pp; - int v1; - - pp = 99; - any_move_linked = 0; - isNonTrivialLinkSequence = 0; +s32 sub_80935B8(struct Move *moves, s32 index) +{ + s32 i; + s32 linkSequenceStart; + bool8 isNonTrivialLinkSequence; + bool8 any_move_linked; + s32 pp; + bool8 v1; + pp = 99; + any_move_linked = FALSE; + isNonTrivialLinkSequence = FALSE; linkSequenceStart = index; + while (linkSequenceStart >= 0) { struct Move *move = &moves[linkSequenceStart]; - if (!((move->moveFlags & MOVE_FLAG_EXISTS) && (move->moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN))) { + + if (!((move->moveFlags & MOVE_FLAG_EXISTS) && (move->moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN))) break; - } - + linkSequenceStart--; } // this is so stupid but it works - isNonTrivialLinkSequence++;isNonTrivialLinkSequence--; + #ifndef NONMATCHING + isNonTrivialLinkSequence++; isNonTrivialLinkSequence--; + #endif - for (i = linkSequenceStart + 1; i < 4; i++) { + for (i = linkSequenceStart + 1; i < MAX_MON_MOVES; i++) { struct Move *move = &moves[i]; - if (!((move->moveFlags & MOVE_FLAG_EXISTS) && (move->moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN))) { + + if (!((move->moveFlags & MOVE_FLAG_EXISTS) && (move->moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN))) break; - } - - isNonTrivialLinkSequence = 1; + + isNonTrivialLinkSequence = TRUE; } - if (!isNonTrivialLinkSequence) { + if (!isNonTrivialLinkSequence) return 99; - } - v1 = 0; + v1 = FALSE; + while (--i >= linkSequenceStart) { struct Move* move = &moves[i]; - if (!(move->moveFlags & MOVE_FLAG_EXISTS)) { + + if (!(move->moveFlags & MOVE_FLAG_EXISTS)) break; - } - if (pp > move->PP) { + + if (pp > move->PP) pp = move->PP; - } - if (move->PP == 0) { - v1 = 1; - } - if (move->moveFlags2 & MOVE_FLAG_REPLACE) { - v1 = 1; - } + if (move->PP == 0) + v1 = TRUE; + if (move->moveFlags2 & MOVE_FLAG_REPLACE) + v1 = TRUE; } - if (!v1) { + if (!v1) return pp; - } - for (i = linkSequenceStart + 1; i < 4; i++) { + for (i = linkSequenceStart + 1; i < MAX_MON_MOVES; i++) { struct Move* move = &moves[i]; - if (!(moves[i].moveFlags & MOVE_FLAG_EXISTS)) { + + if (!(moves[i].moveFlags & MOVE_FLAG_EXISTS)) break; - } if (move->moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN) { move->moveFlags &= ~MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN; - any_move_linked = 1; + any_move_linked = TRUE; } - else { + else break; - } } - if (any_move_linked) { + if (any_move_linked) return 0; - } - else { - return pp; - } + return pp; } -void unk_FixLinkedMovesSetEnabled4(struct Move* moves) { +void unk_FixLinkedMovesSetEnabled4(struct Move *moves) +{ struct Move linkedSequences[4][4]; // all that doing these in a row seems to do is @@ -1010,145 +995,146 @@ void unk_FixLinkedMovesSetEnabled4(struct Move* moves) { unk_LinkedSequencesToMoves4(moves, linkedSequences); } -void unk_FixLinkedMovesSetEnabled8(struct Move* moves) { +void unk_FixLinkedMovesSetEnabled8(struct Move *moves) +{ struct Move linkedSequences[8][8]; + unk_GetLinkedSequences8(moves, linkedSequences); unk_LinkedSequencesToMoves8(moves, linkedSequences); } -void unk_FixLinkedMovesSetEnabled8_v2(struct Move* moves) { +void unk_FixLinkedMovesSetEnabled8_v2(struct Move *moves) +{ struct Move linkedSequences[8][8]; unk_GetLinkedSequences8_v2(moves, linkedSequences); unk_LinkedSequencesToMoves8_v2(moves, linkedSequences); } -int unk_FindMarkedMoveInLinkedSequences44(struct Move moves[4][4]) { - int i, j; +static s32 unk_FindMarkedMoveInLinkedSequences44(struct Move moves[MAX_MON_MOVES][MAX_MON_MOVES]) +{ + s32 i, j; - for (i = 0; i < 4; i++) { - for (j = 0; j < 4; j++) { - if ((moves[i][j].moveFlags & MOVE_FLAG_EXISTS) && (moves[i][j].moveFlags & MOVE_FLAG_INTERNAL_MARKER)) { + for (i = 0; i < MAX_MON_MOVES; i++) { + for (j = 0; j < MAX_MON_MOVES; j++) { + if ((moves[i][j].moveFlags & MOVE_FLAG_EXISTS) && (moves[i][j].moveFlags & MOVE_FLAG_INTERNAL_MARKER)) return i; - } } } + return -1; } -void unk_GetLinkedSequences4(struct Move* moves, struct Move linkedSequences[4][4]) { - int i, j; - int k; - int moveSetIndex; +static void unk_GetLinkedSequences4(struct Move *moves, struct Move linkedSequences[MAX_MON_MOVES][MAX_MON_MOVES]) +{ + s32 i, j; + s32 k; + s32 moveSetIndex; - for (i = 0; i < 4; i++) { - for (j = 0; j < 4; j++) { + for (i = 0; i < MAX_MON_MOVES; i++) { + for (j = 0; j < MAX_MON_MOVES; j++) linkedSequences[i][j].moveFlags = 0; - } } moveSetIndex = -1; - for (j = 0, k = 0; k < 4; j++, k++) { + + for (j = 0, k = 0; k < MAX_MON_MOVES; j++, k++) { if (k == 0 || !(moves[k].moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN)) { moveSetIndex++; j = 0; } + linkedSequences[moveSetIndex][j] = moves[k]; linkedSequences[moveSetIndex][j].moveFlags &= ~MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN; } } +static void unk_LinkedSequencesToMoves4(struct Move *moves, struct Move linkedSequences[MAX_MON_MOVES][MAX_MON_MOVES]) +{ + s32 i, j; + s32 movesCopied; -void unk_LinkedSequencesToMoves4(struct Move* moves, struct Move linkedSequences[4][4]) { - int i, j; - int movesCopied; - - bool8 moves_set[4]; - bool8 moves_enabled[4]; + bool8 moves_set[MAX_MON_MOVES]; + bool8 moves_enabled[MAX_MON_MOVES]; movesCopied = 0; - - // figure out which linked sequences contain set / enabled moves - for (i = 0; i < 4; i++) { + + // Figure out which linked sequences contain set / enabled moves + for (i = 0; i < MAX_MON_MOVES; i++) { moves_set[i] = 0; moves_enabled[i] = 0; - for (j = 0; j < 4; j++) { + for (j = 0; j < MAX_MON_MOVES; j++) { u8 flag; - if (!(linkedSequences[i][j].moveFlags & MOVE_FLAG_EXISTS)) { + if (!(linkedSequences[i][j].moveFlags & MOVE_FLAG_EXISTS)) continue; - } flag = MOVE_FLAG_SET; flag &= linkedSequences[i][j].moveFlags; - if (flag) { + if (flag) moves_set[i] = TRUE; - } - if (linkedSequences[i][j].moveFlags & MOVE_FLAG_ENABLED_FOR_AI) { + + if (linkedSequences[i][j].moveFlags & MOVE_FLAG_ENABLED_FOR_AI) moves_enabled[i] = TRUE; - } } } - for (i = 0; i < 4; i++) { - for (j = 0; j < 4; j++) { - if (linkedSequences[i][j].moveFlags & MOVE_FLAG_EXISTS) { - moves[movesCopied] = linkedSequences[i][j]; + for (i = 0; i < MAX_MON_MOVES; i++) { + for (j = 0; j < MAX_MON_MOVES; j++) { + if (!(linkedSequences[i][j].moveFlags & MOVE_FLAG_EXISTS)) + continue; - if (j == 0) { - moves[movesCopied].moveFlags &= ~MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN; - } - else { - moves[movesCopied].moveFlags |= MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN; - } - - moves[movesCopied].moveFlags &= ~MOVE_FLAG_SET; - moves[movesCopied].moveFlags &= ~MOVE_FLAG_ENABLED_FOR_AI; - if (moves_set[i] && (j == 0)) { - moves[movesCopied].moveFlags |= MOVE_FLAG_SET; - } - if (moves_enabled[i] && (j == 0)) { - moves[movesCopied].moveFlags |= MOVE_FLAG_ENABLED_FOR_AI; - } + moves[movesCopied] = linkedSequences[i][j]; - movesCopied++; - if (movesCopied == 4) { - return; - } - } + if (j == 0) + moves[movesCopied].moveFlags &= ~MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN; + else + moves[movesCopied].moveFlags |= MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN; + + moves[movesCopied].moveFlags &= ~MOVE_FLAG_SET; + moves[movesCopied].moveFlags &= ~MOVE_FLAG_ENABLED_FOR_AI; + + if (moves_set[i] && j == 0) + moves[movesCopied].moveFlags |= MOVE_FLAG_SET; + if (moves_enabled[i] && j == 0) + moves[movesCopied].moveFlags |= MOVE_FLAG_ENABLED_FOR_AI; + + movesCopied++; + if (movesCopied == MAX_MON_MOVES) + return; } } } -// the next two functions are exactly the same -int unk_FindMarkedMoveInLinkedSequences88(struct Move linkedSequences[8][8]) { - int i, j; +// The next two functions are exactly the same +static s32 unk_FindMarkedMoveInLinkedSequences88(struct Move linkedSequences[8][8]) +{ + s32 i, j; for (i = 0; i < 8; i++) { for (j = 0; j < 8; j++) { - if ((linkedSequences[i][j].moveFlags & MOVE_FLAG_EXISTS) && (linkedSequences[i][j].moveFlags & MOVE_FLAG_INTERNAL_MARKER)) { + if ((linkedSequences[i][j].moveFlags & MOVE_FLAG_EXISTS) && (linkedSequences[i][j].moveFlags & MOVE_FLAG_INTERNAL_MARKER)) return i; - } } } - + return -1; } -// I expect the intent was to check for a different flag in this one +// I expect the intent was to check for a different flag in this one... // or the argument is a struct type that does hold the moves as a field -int unk_FindMarkedMoveInLinkedSequences88_v2(struct Move linkedSequences[8][8]) { - int i, j; +static s32 unk_FindMarkedMoveInLinkedSequences88_v2(struct Move linkedSequences[8][8]) +{ + s32 i, j; for (i = 0; i < 8; i++) { for (j = 0; j < 8; j++) { - if ((linkedSequences[i][j].moveFlags & MOVE_FLAG_EXISTS) && (linkedSequences[i][j].moveFlags & MOVE_FLAG_INTERNAL_MARKER)) { + if ((linkedSequences[i][j].moveFlags & MOVE_FLAG_EXISTS) && (linkedSequences[i][j].moveFlags & MOVE_FLAG_INTERNAL_MARKER)) return i; - } } } - + return -1; } @@ -1158,47 +1144,54 @@ int unk_FindMarkedMoveInLinkedSequences88_v2(struct Move linkedSequences[8][8]) // it seems to find all the _actually_ separate moves, and split them // out into link sequences in the destination linkedSequences -void unk_GetLinkedSequences8(struct Move* moves, struct Move linkedSequences[8][8]) { - int i, j; - int k; - int moveSetIndex; +static void unk_GetLinkedSequences8(struct Move *moves, struct Move linkedSequences[8][8]) +{ + s32 i, j; + s32 k; + s32 moveSetIndex; // clear out linkedSequences for (i = 0; i < 8; i++) { - for (j = 0; j < 8; j++) { + for (j = 0; j < 8; j++) linkedSequences[i][j].moveFlags = 0; - } } moveSetIndex = -1; + for (j = 0, k = 0; k < 8; j++, k++) { struct Move* move = &moves[k]; + if (k == 0 || !(move->moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN)) { moveSetIndex++; j = 0; } + linkedSequences[moveSetIndex][j] = *move; linkedSequences[moveSetIndex][j].moveFlags &= ~MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN; } } -void unk_GetLinkedSequences8_v2(struct Move* moves, struct Move linkedSequences[8][8]) { - int i, j; - int k; - int moveSetIndex; +static void unk_GetLinkedSequences8_v2(struct Move *moves, struct Move linkedSequences[8][8]) +{ + s32 i, j; + s32 k; + s32 moveSetIndex; for (i = 0; i < 8; i++) { - for (j = 0; j < 8; j++) { + for (j = 0; j < 8; j++) linkedSequences[i][j].moveFlags = 0; - } } + moveSetIndex = -1; + for (j = 0, k = 0; k < 8; j++, k++) { struct Move* move = &moves[k]; + if (k == 0 || !(move->moveFlags & 2)) { moveSetIndex++; j = 0; } + linkedSequences[moveSetIndex][j] = *move; linkedSequences[moveSetIndex][j].moveFlags &= ~MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN; } @@ -1207,15 +1200,16 @@ void unk_GetLinkedSequences8_v2(struct Move* moves, struct Move linkedSequences[ // the next 2 functions are again exactly the same // these functions are the same as unk_LinkedSequencesToMoves4 but for [8][8] linkedSequences // instead of [4][4] linkedSequences -void unk_LinkedSequencesToMoves8(struct Move* moves, struct Move linkedSequences[8][8]) { +static void unk_LinkedSequencesToMoves8(struct Move *moves, struct Move linkedSequences[8][8]) +{ int i, j; int movesCopied; - + bool8 moveFlags8[8]; bool8 moveFlags4[8]; movesCopied = 0; - + for (i = 0; i < 8; i++) { moveFlags8[i] = 0; moveFlags4[i] = 0; @@ -1223,60 +1217,57 @@ void unk_LinkedSequencesToMoves8(struct Move* moves, struct Move linkedSequences for (j = 0; j < 8; j++) { u8 flag; - if (!(linkedSequences[i][j].moveFlags & MOVE_FLAG_EXISTS)) { + if (!(linkedSequences[i][j].moveFlags & MOVE_FLAG_EXISTS)) continue; - } flag = MOVE_FLAG_SET; flag &= linkedSequences[i][j].moveFlags; - if (flag) { + + if (flag) moveFlags8[i] = TRUE; - } - if (linkedSequences[i][j].moveFlags & MOVE_FLAG_ENABLED_FOR_AI) { + + if (linkedSequences[i][j].moveFlags & MOVE_FLAG_ENABLED_FOR_AI) moveFlags4[i] = TRUE; - } } } for (i = 0; i < 8; i++) { for (j = 0; j < 8; j++) { - if (linkedSequences[i][j].moveFlags & MOVE_FLAG_EXISTS) { - moves[movesCopied] = linkedSequences[i][j]; + if (!(linkedSequences[i][j].moveFlags & MOVE_FLAG_EXISTS)) + continue; - if (j == 0) { - moves[movesCopied].moveFlags &= ~MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN; - } - else { - moves[movesCopied].moveFlags |= MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN; - } - - moves[movesCopied].moveFlags &= ~MOVE_FLAG_SET; - moves[movesCopied].moveFlags &= ~MOVE_FLAG_ENABLED_FOR_AI; - if (moveFlags8[i] && (j == 0)) { - moves[movesCopied].moveFlags |= MOVE_FLAG_SET; - } - if (moveFlags4[i] && (j == 0)) { - moves[movesCopied].moveFlags |= MOVE_FLAG_ENABLED_FOR_AI; - } + moves[movesCopied] = linkedSequences[i][j]; - movesCopied++; - if (movesCopied == 8) { - return; - } - } + if (j == 0) + moves[movesCopied].moveFlags &= ~MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN; + else + moves[movesCopied].moveFlags |= MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN; + + moves[movesCopied].moveFlags &= ~MOVE_FLAG_SET; + moves[movesCopied].moveFlags &= ~MOVE_FLAG_ENABLED_FOR_AI; + + if (moveFlags8[i] && (j == 0)) + moves[movesCopied].moveFlags |= MOVE_FLAG_SET; + if (moveFlags4[i] && (j == 0)) + moves[movesCopied].moveFlags |= MOVE_FLAG_ENABLED_FOR_AI; + + movesCopied++; + if (movesCopied == 8) + return; } } } -void unk_LinkedSequencesToMoves8_v2(struct Move* moves, struct Move linkedSequences[8][8]) { - int i, j; - int movesCopied; - +static void unk_LinkedSequencesToMoves8_v2(struct Move *moves, struct Move linkedSequences[8][8]) +{ + s32 i, j; + s32 movesCopied; + bool8 moveFlags8[8]; bool8 moveFlags4[8]; movesCopied = 0; - + for (i = 0; i < 8; i++) { moveFlags8[i] = 0; moveFlags4[i] = 0; @@ -1284,170 +1275,174 @@ void unk_LinkedSequencesToMoves8_v2(struct Move* moves, struct Move linkedSequen for (j = 0; j < 8; j++) { u8 flag; - if (!(linkedSequences[i][j].moveFlags & MOVE_FLAG_EXISTS)) { + if (!(linkedSequences[i][j].moveFlags & MOVE_FLAG_EXISTS)) continue; - } flag = MOVE_FLAG_SET; flag &= linkedSequences[i][j].moveFlags; - if (flag) { + + if (flag) moveFlags8[i] = TRUE; - } - if (linkedSequences[i][j].moveFlags & MOVE_FLAG_ENABLED_FOR_AI) { + + if (linkedSequences[i][j].moveFlags & MOVE_FLAG_ENABLED_FOR_AI) moveFlags4[i] = TRUE; - } } } for (i = 0; i < 8; i++) { for (j = 0; j < 8; j++) { - if (linkedSequences[i][j].moveFlags & MOVE_FLAG_EXISTS) { - moves[movesCopied] = linkedSequences[i][j]; + if (!(linkedSequences[i][j].moveFlags & MOVE_FLAG_EXISTS)) + continue; - if (j == 0) { - moves[movesCopied].moveFlags &= ~MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN; - } - else { - moves[movesCopied].moveFlags |= MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN; - } - - moves[movesCopied].moveFlags &= ~MOVE_FLAG_SET; - moves[movesCopied].moveFlags &= ~MOVE_FLAG_ENABLED_FOR_AI; - if (moveFlags8[i] && (j == 0)) { - moves[movesCopied].moveFlags |= MOVE_FLAG_SET; - } - if (moveFlags4[i] && (j == 0)) { - moves[movesCopied].moveFlags |= MOVE_FLAG_ENABLED_FOR_AI; - } + moves[movesCopied] = linkedSequences[i][j]; - movesCopied++; - if (movesCopied == 8) { - return; - } - } + if (j == 0) + moves[movesCopied].moveFlags &= ~MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN; + else + moves[movesCopied].moveFlags |= MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN; + + moves[movesCopied].moveFlags &= ~MOVE_FLAG_SET; + moves[movesCopied].moveFlags &= ~MOVE_FLAG_ENABLED_FOR_AI; + + if (moveFlags8[i] && (j == 0)) + moves[movesCopied].moveFlags |= MOVE_FLAG_SET; + if (moveFlags4[i] && (j == 0)) + moves[movesCopied].moveFlags |= MOVE_FLAG_ENABLED_FOR_AI; + + movesCopied++; + if (movesCopied == 8) + return; } } } - -// the next two are again the same -void RemoveLinkSequenceFromMoves8_v2(struct Move* moves, int index) { - int i; - int copiedMoves; +// The next two are the same again +UNUSED static void RemoveLinkSequenceFromMoves8_v2(struct Move *moves, s32 index) +{ + s32 i; + s32 copiedMoves; struct Move moveSet[8]; - + moves[index].moveFlags = 0; + for (i = index + 1; i < 8; i++) { struct Move* move = &moves[i]; - // TODO: don't do this trickery + #ifndef NONMATCHING asm(""); - if (!(move->moveFlags & MOVE_FLAG_EXISTS)) { + #endif + + if (!(move->moveFlags & MOVE_FLAG_EXISTS)) break; - } - if (!(move->moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN)) { + + if (!(move->moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN)) break; - } move->moveFlags = 0; } copiedMoves = 0; + for (i = 0; i < 8; i++) { - if (moves[i].moveFlags & MOVE_FLAG_EXISTS) { + if (moves[i].moveFlags & MOVE_FLAG_EXISTS) moveSet[copiedMoves++] = moves[i]; - } } - while (copiedMoves < 8) { + while (copiedMoves < 8) moveSet[copiedMoves++].moveFlags = 0; - } - for (i = 0; i < 8; i++) { + for (i = 0; i < 8; i++) moves[i] = moveSet[i]; - } } -void RemoveLinkSequenceFromMoves8(struct Move* moves, int index) { - int i; - int copiedMoves; +void RemoveLinkSequenceFromMoves8(struct Move *moves, s32 index) +{ + s32 i; + s32 copiedMoves; struct Move moveSet[8]; - + // remove link sequence (set flags to 0) moves[index].moveFlags = 0; + for (i = index + 1; i < 8; i++) { struct Move* move = &moves[i]; + + #ifndef NONMATCHING asm(""); - if (!(move->moveFlags & MOVE_FLAG_EXISTS)) { + #endif + + if (!(move->moveFlags & MOVE_FLAG_EXISTS)) break; - } - if (!(move->moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN)) { + + if (!(move->moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN)) break; - } move->moveFlags = 0; } // copy over other moves copiedMoves = 0; + for (i = 0; i < 8; i++) { - if (moves[i].moveFlags & MOVE_FLAG_EXISTS) { + if (moves[i].moveFlags & MOVE_FLAG_EXISTS) moveSet[copiedMoves++] = moves[i]; - } } // fill with nonexistent moves - while (copiedMoves < 8) { + while (copiedMoves < 8) moveSet[copiedMoves++].moveFlags = 0; - } // copy back to original moves pointer - for (i = 0; i < 8; i++) { + for (i = 0; i < 8; i++) moves[i] = moveSet[i]; - } } -int unk_MoveIDPrintMoveDescription(int a1, u16 moveID, int a3, struct subStruct_203B240** a4) { +s32 unk_MoveIDPrintMoveDescription(s32 a1, u16 moveID, s32 a3, struct subStruct_203B240 **a4) +{ struct Move move; InitPokemonMove(&move, moveID); return unk_PrintMoveDescription(a1, &move, a3, a4); } -int unk_MovePrintMoveDescription(int a1, struct Move* move, int a3, struct subStruct_203B240** a4) { +UNUSED static s32 unk_MovePrintMoveDescription(s32 a1, struct Move *move, s32 a3, struct subStruct_203B240 **a4) +{ struct Move newMove; CopyAndResetMove(&newMove, move); return unk_PrintMoveDescription(a1, &newMove, a3, a4); } -int unk_PrintMoveDescription(int x, struct Move* move, int a3, struct subStruct_203B240** a4) { - char* moveDescription; - int y; - char buffer[800]; - +s32 unk_PrintMoveDescription(s32 x, struct Move *move, s32 a3, struct subStruct_203B240 **a4) +{ + u8 *moveDescription; + s32 y; + u8 buffer[800]; + sub_80073B8(a3); sub_80928C0(gAvailablePokemonNames, move, 0); xxx_format_and_draw(8 * x + 16, 0, gUnknown_8109930, a3, 0); y = 19; - moveDescription = gMovesData[move->id].description; - if (moveDescription[0] == '*') - { + moveDescription = sMovesData[move->id].description; + + if (moveDescription[0] == '*') { y = 16; ++moveDescription; } + xxx_format_and_draw(4, y, moveDescription, a3, 0); unk_MovePrintData(move, a3); sub_80073E0(a3); - strcpy(buffer, gMovesData[move->id].description); + strcpy(buffer, sMovesData[move->id].description); return sub_8097DF0(buffer, a4); } -void unk_MovePrintData(struct Move* move, int y) { +static void unk_MovePrintData(struct Move *move, s32 y) +{ u8 type; s32 power; - const char* text; - + const u8 *text; + sub_80078A4(y, 4, 72, 200, COLOR_WHITE_2); sub_8092D54(gAvailablePokemonNames, move); xxx_format_and_draw(4, 74, gUnknown_810CF00, y, 0); @@ -1459,118 +1454,118 @@ void unk_MovePrintData(struct Move* move, int y) { gUnknown_202DE30 = power; } -void CopyAndResetMove(struct Move* dest, struct Move* src) { +static void CopyAndResetMove(struct Move *dest, struct Move *src) +{ if (src->moveFlags & MOVE_FLAG_EXISTS) { dest->moveFlags = src->moveFlags; dest->moveFlags2 = 0; dest->id = src->id; - dest->PP = gMovesData[src->id].basePP; - dest->ginseng = src->PP; // this seems horribly bugged + dest->PP = sMovesData[src->id].basePP; + dest->ginseng = src->PP; // This seems horribly bugged } - else { + else dest->moveFlags = 0; - } } -void CopyAndResetMoves(struct Move *destMoves, struct Move *srcMoves) { - int i; +void CopyAndResetMoves(struct Move *destMoves, struct Move *srcMoves) +{ + s32 i; - for (i = 0; i < 4; i++) { + for (i = 0; i < MAX_MON_MOVES; i++) { if (srcMoves[i].moveFlags & 1) { destMoves[i].moveFlags = srcMoves[i].moveFlags; destMoves[i].moveFlags2 = 0; destMoves[i].id = srcMoves[i].id; - destMoves[i].PP = gMovesData[srcMoves[i].id].basePP; - destMoves[i].ginseng = srcMoves[i].PP; + destMoves[i].PP = sMovesData[srcMoves[i].id].basePP; + destMoves[i].ginseng = srcMoves[i].PP; // This seems horribly bugged } - else { + else destMoves[i].moveFlags = 0; - } } // possibly destMoves is not just an array and this is the // next struct field // this index would be out of bounds after all - destMoves[4].moveFlags = 0; + destMoves[MAX_MON_MOVES].moveFlags = 0; } -void CopyBareMoveData(struct Move *destMoves, struct Move *srcMoves) { - int i; +void CopyBareMoveData(struct Move *destMoves, struct Move *srcMoves) +{ + s32 i; - for (i = 0; i < 4; i++) { + for (i = 0; i < MAX_MON_MOVES; i++) { destMoves[i].moveFlags = srcMoves[i].moveFlags; destMoves[i].id = srcMoves[i].id; destMoves[i].PP = srcMoves[i].ginseng; } } -void unk_CopyMoves4To8AndClearFlag2Unk4(struct Move* destMoves, struct Move* srcMoves) { - int movesCopied; +void unk_CopyMoves4To8AndClearFlag2Unk4(struct Move *destMoves, struct Move *srcMoves) +{ + s32 movesCopied; movesCopied = 0; - for (movesCopied = 0; movesCopied < 4; movesCopied++) { - if (!(srcMoves[movesCopied].moveFlags & MOVE_FLAG_EXISTS)) { + + for (movesCopied = 0; movesCopied < MAX_MON_MOVES; movesCopied++) { + if (!(srcMoves[movesCopied].moveFlags & MOVE_FLAG_EXISTS)) break; - } destMoves[movesCopied] = srcMoves[movesCopied]; destMoves[movesCopied].moveFlags2 &= ~MOVE_FLAG2_UNK4; } - while (movesCopied < 8) { + while (movesCopied < 8) destMoves[movesCopied++].moveFlags = 0; - } } -void unk_CopyMoves4To8(struct Move* destMoves, struct Move* srcMoves) { - int movesCopied; +void unk_CopyMoves4To8(struct Move *destMoves, struct Move *srcMoves) +{ + s32 movesCopied; movesCopied = 0; - for (movesCopied = 0; movesCopied < 4; movesCopied++) { - if (!(srcMoves[movesCopied].moveFlags & MOVE_FLAG_EXISTS)) { + for (movesCopied = 0; movesCopied < MAX_MON_MOVES; movesCopied++) { + if (!(srcMoves[movesCopied].moveFlags & MOVE_FLAG_EXISTS)) break; - } destMoves[movesCopied] = srcMoves[movesCopied]; } - while (movesCopied < 8) { + while (movesCopied < 8) destMoves[movesCopied++].moveFlags = 0; - } } -void sub_8094060(struct Move* srcMoves, struct Move* destMoves) { - int i, j; +void sub_8094060(struct Move *srcMoves, struct Move *destMoves) +{ + s32 i, j; j = 0; for (i = 0; i < 8; i++) { struct Move* srcMove = &srcMoves[i]; struct Move* destMove; - if (!(srcMove->moveFlags & MOVE_FLAG_EXISTS)) { + + if (!(srcMove->moveFlags & MOVE_FLAG_EXISTS)) continue; - } - - if (j >= 4) { + + if (j >= MAX_MON_MOVES) break; - } + destMove = &destMoves[j]; *destMove = *srcMove; j++; } - while (j < 4) { + while (j < MAX_MON_MOVES) destMoves[j++].moveFlags = 0; - } } -void SavePokemonMove(struct unkStruct_8094924 *r0, struct Move *move) +static void SavePokemonMove(struct unkStruct_8094924 *r0, struct Move *move) { SaveIntegerBits(r0, &move->moveFlags, 4); SaveIntegerBits(r0, &move->id, 9); SaveIntegerBits(r0, &move->PP, 7); } -void RestorePokemonMove(struct unkStruct_8094924 *r0, struct Move *move) +static void RestorePokemonMove(struct unkStruct_8094924 *r0, struct Move *move) { RestoreIntegerBits(r0, &move->moveFlags, 4); RestoreIntegerBits(r0, &move->id, 9); @@ -1579,23 +1574,21 @@ void RestorePokemonMove(struct unkStruct_8094924 *r0, struct Move *move) void SavePokemonMoves(struct unkStruct_8094924 *r0, struct Move *moveSet) { - s32 iVar4; - for(iVar4 = 0; iVar4 < MAX_MON_MOVES; iVar4++) - { - SavePokemonMove(r0, &moveSet[iVar4]); - } + s32 i; + + for (i = 0; i < MAX_MON_MOVES; i++) + SavePokemonMove(r0, &moveSet[i]); } void RestorePokemonMoves(struct unkStruct_8094924 *r0, struct Move *moveSet) { - s32 iVar4; - for(iVar4 = 0; iVar4 < MAX_MON_MOVES; iVar4++) - { - RestorePokemonMove(r0, &moveSet[iVar4]); - } + s32 i; + + for (i = 0; i < MAX_MON_MOVES; i++) + RestorePokemonMove(r0, &moveSet[i]); } -void sub_8094148(struct unkStruct_8094924 *r0, struct Move *move) +static void sub_8094148(struct unkStruct_8094924 *r0, struct Move *move) { SaveIntegerBits(r0, &move->moveFlags, 4); SaveIntegerBits(r0, &move->moveFlags2, 1); @@ -1606,16 +1599,15 @@ void sub_8094148(struct unkStruct_8094924 *r0, struct Move *move) void sub_8094184(struct unkStruct_8094924 *r0, struct unkStruct_8094184 *r1) { - s32 r4; + s32 i; + + for (i = 0; i < MAX_MON_MOVES; i++) + sub_8094148(r0, &r1->moves[i]); - for(r4 = 0; r4 < MAX_MON_MOVES; r4++) - { - sub_8094148(r0, &r1->moves[r4]); - } SaveIntegerBits(r0, &r1->unk20, 8); } -void sub_80941B0(struct unkStruct_8094924 *r0, struct Move *move) +static void sub_80941B0(struct unkStruct_8094924 *r0, struct Move *move) { memset(move, 0, sizeof(struct Move)); RestoreIntegerBits(r0, &move->moveFlags, 4); @@ -1627,34 +1619,26 @@ void sub_80941B0(struct unkStruct_8094924 *r0, struct Move *move) void sub_80941FC(struct unkStruct_8094924 *r0, struct unkStruct_8094184 *r1) { - s32 iVar4; - for(iVar4 = 0; iVar4 < MAX_MON_MOVES; iVar4++) - { - sub_80941B0(r0, &r1->moves[iVar4]); - } + s32 i; + + for (i = 0; i < MAX_MON_MOVES; i++) + sub_80941B0(r0, &r1->moves[i]); + r1->unk20 = 0; RestoreIntegerBits(r0, &r1->unk20, 8); } bool8 DoesMoveCharge(u16 move) { - if(move == MOVE_SOLARBEAM) - return TRUE; - if(move == MOVE_SKY_ATTACK) - return TRUE; - if(move == MOVE_RAZOR_WIND) - return TRUE; - if(move == MOVE_FOCUS_PUNCH) - return TRUE; - if(move == MOVE_SKULL_BASH) - return TRUE; - if(move == MOVE_FLY) - return TRUE; - if(move == MOVE_BOUNCE) - return TRUE; - if(move == MOVE_DIVE) - return TRUE; - if(move == MOVE_DIG) - return TRUE; + if (move == MOVE_SOLARBEAM) return TRUE; + if (move == MOVE_SKY_ATTACK) return TRUE; + if (move == MOVE_RAZOR_WIND) return TRUE; + if (move == MOVE_FOCUS_PUNCH) return TRUE; + if (move == MOVE_SKULL_BASH) return TRUE; + if (move == MOVE_FLY) return TRUE; + if (move == MOVE_BOUNCE) return TRUE; + if (move == MOVE_DIVE) return TRUE; + if (move == MOVE_DIG) return TRUE; + return FALSE; -} +} \ No newline at end of file diff --git a/src/party_list_menu.c b/src/party_list_menu.c index c525025d2..5cb156741 100644 --- a/src/party_list_menu.c +++ b/src/party_list_menu.c @@ -1,25 +1,24 @@ #include "global.h" -#include "constants/dungeon.h" -#include "item.h" -#include "memory.h" -#include "pokemon.h" -#include "text1.h" -#include "text2.h" -#include "text_util.h" -#include "team_inventory.h" -#include "constants/move.h" #include "code_800D090.h" -#include "menu_input.h" -#include "moves.h" -#include "kecleon_bros.h" +#include "code_80118A4.h" #include "code_80130A8.h" #include "code_801B3C0.h" -#include "code_80118A4.h" +#include "constants/dungeon.h" #include "event_flag.h" +#include "item.h" +#include "kecleon_bros.h" +#include "memory.h" +#include "menu_input.h" +#include "moves.h" +#include "pokemon.h" +#include "team_inventory.h" +#include "text_util.h" +#include "text1.h" +#include "text2.h" +// size: 0x280 struct unkStruct_203B2B8 { - // size: 0x280 s32 state; s32 fallbackState; bool8 unk8; diff --git a/src/pokemon_3.c b/src/pokemon_3.c index 995768fc7..126e02e58 100644 --- a/src/pokemon_3.c +++ b/src/pokemon_3.c @@ -1,5 +1,4 @@ #include "global.h" - #include "pokemon.h" #include "pokemon_3.h" #include "random.h" @@ -12,6 +11,7 @@ #include "friend_area.h" #include "luminous_cave.h" #include "code_8097670.h" +#include "moves.h" extern u8 *gIQSkillNames[]; extern u8 *gIQSkillDescriptions[]; @@ -48,15 +48,11 @@ extern s32 gUnknown_810AC90[10]; extern void SaveDungeonLocation(struct unkStruct_8094924*, struct DungeonLocation*); extern void xxx_save_poke_sub_c_808F41C(struct unkStruct_8094924*, struct unkPokeSubStruct_C*); -extern void SavePokemonMoves(struct unkStruct_8094924*, struct Move*); void RestoreDungeonLocation(struct unkStruct_8094924*, struct DungeonLocation*); void xxx_restore_poke_sub_c_808F410(struct unkStruct_8094924*, struct unkPokeSubStruct_C*); -void RestorePokemonMoves(struct unkStruct_8094924*, struct Move*); -extern void sub_8094184(struct unkStruct_8094924*, void*); extern void sub_809449C(struct unkStruct_8094924*, void*); extern void sub_808F448(struct unkStruct_8094924*, struct unkStruct_808E6F4*); -extern void sub_80941FC(struct unkStruct_8094924*, void*); extern void sub_809447C(struct unkStruct_8094924*, void*); extern void sub_808F428(struct unkStruct_8094924*, struct unkStruct_808E6F4*); s16 GetPokemonEvolveConditions(s16 index, struct unkEvolve *r1); diff --git a/src/pokemon_mid.c b/src/pokemon_mid.c index 2d76d456d..9e0dd42bf 100644 --- a/src/pokemon_mid.c +++ b/src/pokemon_mid.c @@ -1,14 +1,14 @@ #include "global.h" -#include "pokemon.h" -#include "pokemon_3.h" -#include "pokemon_mid.h" +#include "code_800D090.h" +#include "constants/colors.h" +#include "constants/move_id.h" #include "file_system.h" #include "item.h" #include "moves.h" +#include "pokemon.h" +#include "pokemon_3.h" +#include "pokemon_mid.h" #include "subStruct_203B240.h" -#include "constants/colors.h" -#include "constants/move_id.h" -#include "code_800D090.h" #include "text_util.h" extern struct MonsterDataEntry *gMonsterParameters; @@ -33,12 +33,13 @@ extern struct LevelData gLevelCurrentData[]; extern int sprintf(char *, const char *, ...); extern u32 ReturnIntFromChar(u8 r0); -extern void CopyAndResetMoves(void*, void*); extern void sub_80943A0(void*, s32); extern void xxx_pokemon2_to_pokemonstruct_808DF44(struct PokemonStruct*, struct PokemonStruct2*); -extern u8* DecompressMoveID(u8* a1, u16* a2); +extern const u8 *DecompressMoveID(const u8 *a1, u16 *a2); extern u32 sub_8097DF0(char *, struct subStruct_203B240 **); +extern u8 GetBodySize(s16 index); + struct unkStruct_8107654 { s16 unk0; s16 fill2; @@ -543,7 +544,7 @@ void xxx_pokemonstruct_to_pokemon2_808DE50(struct PokemonStruct2 * a1, struct Po } a1->currExp = pokemon->currExp; - CopyAndResetMoves(&a1->moves, &pokemon->moves); + CopyAndResetMoves(a1->moves.moves, pokemon->moves); for (i = 0; i < POKEMON_NAME_LENGTH; i++) { a1->name[i] = pokemon->name[i]; @@ -571,8 +572,6 @@ void xxx_pokemon2_to_pokemonstruct_index_808DF2C(s32 a1, struct PokemonStruct2* xxx_pokemon2_to_pokemonstruct_808DF44(&a1[gRecruitedPokemonRef->pokemon], a2); } -extern void CopyBareMoveData(struct Move*, struct unkStruct_8094184*); - void xxx_pokemon2_to_pokemonstruct_808DF44(struct PokemonStruct* pokemon, struct PokemonStruct2* a2) { @@ -594,7 +593,7 @@ void xxx_pokemon2_to_pokemonstruct_808DF44(struct PokemonStruct* pokemon, struct } pokemon->currExp = a2->currExp; - CopyBareMoveData(pokemon->moves, &a2->moves); + CopyBareMoveData(pokemon->moves, a2->moves.moves); for (i = 0; i < POKEMON_NAME_LENGTH; i++) { pokemon->name[i] = a2->name[i]; @@ -643,7 +642,7 @@ void GetPokemonLevelData(struct LevelData* a1, s16 _id, s32 level) *a1 = gLevelCurrentData[level]; } -u8* DecompressMoveID(u8* a1, u16* moveID) +const u8* DecompressMoveID(const u8* a1, u16* moveID) { u32 r1 = *a1++; u32 r3; @@ -672,7 +671,7 @@ u8* DecompressMoveID(u8* a1, u16* moveID) s32 sub_808E0AC(u16* a1, s16 species, s32 a3, s32 IQPoints) { - u8* stream; + const u8* stream; u16 moveID; // moveID s32 count; register s32 _species asm("r2"); // weird regalloc @@ -721,7 +720,7 @@ bool8 CanMonLearnMove(u16 moveID, s16 _species) u16 levelUpMoveID; u16 HMTMMoveID; s32 species = _species; // r4 - u8* learnsetPtr; + const u8* learnsetPtr; if (species == MONSTER_DECOY) return 0; if (species == MONSTER_NONE) return 0; @@ -763,7 +762,7 @@ s32 sub_808E218(struct unkStruct_808E218_arg* a1, struct PokemonStruct* pokemon) sequence_length = GetEvolutionSequence(pokemon, evolve_sequence); for (i = 0; i < sequence_length; i++) { - u8* ptr; + const u8 *ptr; u16 result; ptr = GetLevelUpMoves(evolve_sequence[i].speciesNum); diff --git a/src/status_checks_1.c b/src/status_checks_1.c index 028c78708..da7b29f3e 100644 --- a/src/status_checks_1.c +++ b/src/status_checks_1.c @@ -25,6 +25,7 @@ extern u8 *gUnknown_80F8994[]; extern u8 *gUnknown_80F8968[]; extern u8 *gUnknown_80F8988[]; extern u8 gUnknown_8106FA4[]; +void CopyCyanMonsterNametoBuffer(u8 *buffer, s16 index); s32 sub_8070828(struct Entity *pokemon, bool8 displayMessage) { diff --git a/sym_ewram.txt b/sym_ewram.txt index 21f40d03a..ed4a9e415 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -799,15 +799,7 @@ gLevelCurrentData: /* 20384F0 */ .include "src/friend_area.o" .space 0x2 -gWazaParametersFile: /* 2038C64 */ - .space 0x4 - -gMovesData: /* 2038C68 */ - .space 0x4 - -gMoveLearnsets: /* 2038C6C */ - .space 0x4 - + .include "src/moves.o" .include "src/game_options.o" .include "src/play_time.o"