Clean moves.c

This commit is contained in:
Kermalis 2023-09-01 04:09:46 -04:00
parent 98fa653569
commit c04159817d
18 changed files with 783 additions and 810 deletions

View File

@ -1,6 +1,7 @@
#ifndef GUARD_CODE_809447C_H
#define GUARD_CODE_809447C_H
// size: 0xC
struct unkStruct_80928C0
{
u32 unk0;

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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)
{

View File

@ -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 *);

View File

@ -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);

View File

@ -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;

View File

@ -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;

File diff suppressed because it is too large Load Diff

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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)
{

View File

@ -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"