diff --git a/docs/tutorials/how_to_new_pokemon.md b/docs/tutorials/how_to_new_pokemon.md index de2d41d57c..100741de52 100644 --- a/docs/tutorials/how_to_new_pokemon.md +++ b/docs/tutorials/how_to_new_pokemon.md @@ -314,7 +314,8 @@ Cry_Pecharunt:: Then we add the cry ID to [include/constants/cries.h](https://github.com/rh-hideout/pokeemerald-expansion/blob/master/include/constants/cries.h): ```diff -enum { +enum PokemonCry +{ CRY_NONE, ... #if P_FAMILY_TERAPAGOS @@ -371,7 +372,8 @@ Edit [include/constants/pokedex.h](https://github.com/rh-hideout/pokeemerald-exp ```diff // National Pokedex order -enum { +enum NationalDexOrder +{ NATIONAL_DEX_NONE, // Kanto NATIONAL_DEX_BULBASAUR, @@ -394,7 +396,8 @@ Do keep in mind that if you intend to add your new species to the Hoenn Dex, you ```diff // Hoenn Pokedex order -enum { +enum HoennDexOrder +{ HOENN_DEX_NONE, HOENN_DEX_TREECKO, ... diff --git a/include/battle.h b/include/battle.h index 10021aebd3..821aa995e1 100644 --- a/include/battle.h +++ b/include/battle.h @@ -755,7 +755,7 @@ struct BattleStruct u8 supremeOverlordCounter[MAX_BATTLERS_COUNT]; u8 shellSideArmCategory[MAX_BATTLERS_COUNT][MAX_BATTLERS_COUNT]; u8 speedTieBreaks; // MAX_BATTLERS_COUNT! values. - u8 categoryOverride; // for Z-Moves and Max Moves + enum DamageCategory categoryOverride:8; // for Z-Moves and Max Moves u16 commanderActive[MAX_BATTLERS_COUNT]; u32 stellarBoostFlags[NUM_BATTLE_SIDES]; // stored as a bitfield of flags for all types for each side u8 monCausingSleepClause[NUM_BATTLE_SIDES]; // Stores which pokemon on a given side is causing Sleep Clause to be active as the mon's index in the party diff --git a/include/battle_ai_util.h b/include/battle_ai_util.h index ff9ea73d3b..2144056cd5 100644 --- a/include/battle_ai_util.h +++ b/include/battle_ai_util.h @@ -128,7 +128,7 @@ u32 CountNegativeStatStages(u32 battlerId); // move checks bool32 IsAffectedByPowder(u32 battler, u32 ability, enum ItemHoldEffect holdEffect); -bool32 MovesWithCategoryUnusable(u32 attacker, u32 target, u32 category); +bool32 MovesWithCategoryUnusable(u32 attacker, u32 target, enum DamageCategory category); s32 AI_WhichMoveBetter(u32 move1, u32 move2, u32 battlerAtk, u32 battlerDef, s32 noOfHitsToKo); struct SimulatedDamage AI_CalcDamageSaveBattlers(u32 move, u32 battlerAtk, u32 battlerDef, uq4_12_t *typeEffectiveness, enum AIConsiderGimmick considerGimmickAtk, enum AIConsiderGimmick considerGimmickDef); struct SimulatedDamage AI_CalcDamage(u32 move, u32 battlerAtk, u32 battlerDef, uq4_12_t *typeEffectiveness, enum AIConsiderGimmick considerGimmickAtk, enum AIConsiderGimmick considerGimmickDef, u32 weather); @@ -141,8 +141,8 @@ uq4_12_t AI_GetMoveEffectiveness(u32 move, u32 battlerAtk, u32 battlerDef); u16 *GetMovesArray(u32 battler); bool32 IsConfusionMoveEffect(enum BattleMoveEffects moveEffect); bool32 HasMove(u32 battlerId, u32 move); -bool32 HasOnlyMovesWithCategory(u32 battlerId, u32 category, bool32 onlyOffensive); -bool32 HasMoveWithCategory(u32 battler, u32 category); +bool32 HasOnlyMovesWithCategory(u32 battlerId, enum DamageCategory category, bool32 onlyOffensive); +bool32 HasMoveWithCategory(u32 battler, enum DamageCategory category); bool32 HasMoveWithType(u32 battler, u32 type); bool32 HasMoveWithEffect(u32 battlerId, enum BattleMoveEffects moveEffect); bool32 HasBattlerSideMoveWithEffect(u32 battler, u32 effect); @@ -233,8 +233,8 @@ struct BattlePokemon *AllocSaveBattleMons(void); void FreeRestoreBattleMons(struct BattlePokemon *savedBattleMons); s32 CountUsablePartyMons(u32 battlerId); bool32 IsPartyFullyHealedExceptBattler(u32 battler); -bool32 PartyHasMoveCategory(u32 battlerId, u32 category); -bool32 SideHasMoveCategory(u32 battlerId, u32 category); +bool32 PartyHasMoveCategory(u32 battlerId, enum DamageCategory category); +bool32 SideHasMoveCategory(u32 battlerId, enum DamageCategory category); // score increases u32 IncreaseStatUpScore(u32 battlerAtk, u32 battlerDef, enum StatChange statId); diff --git a/include/battle_util.h b/include/battle_util.h index 1bd4017a19..62b959cfe3 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -309,7 +309,7 @@ void ClearIllusionMon(u32 battler); u32 GetIllusionMonPartyId(struct Pokemon *party, struct Pokemon *mon, struct Pokemon *partnerMon); bool32 SetIllusionMon(struct Pokemon *mon, u32 battler); bool32 ShouldGetStatBadgeBoost(u16 flagId, u32 battler); -u32 GetBattleMoveCategory(u32 move); +enum DamageCategory GetBattleMoveCategory(u32 move); void SetDynamicMoveCategory(u32 battlerAtk, u32 battlerDef, u32 move); bool32 CanFling(u32 battler); bool32 IsTelekinesisBannedSpecies(u16 species); @@ -317,7 +317,7 @@ bool32 IsHealBlockPreventingMove(u32 battler, u32 move); bool32 IsBelchPreventingMove(u32 battler, u32 move); bool32 HasEnoughHpToEatBerry(u32 battler, u32 hpFraction, u32 itemId); bool32 IsPartnerMonFromSameTrainer(u32 battler); -u8 GetCategoryBasedOnStats(u32 battler); +enum DamageCategory GetCategoryBasedOnStats(u32 battler); void SetShellSideArmCategory(void); bool32 MoveIsAffectedBySheerForce(u32 move); bool32 TestIfSheerForceAffected(u32 battler, u16 move); diff --git a/include/constants/cries.h b/include/constants/cries.h index 554ffafc96..e309739462 100644 --- a/include/constants/cries.h +++ b/include/constants/cries.h @@ -1,7 +1,8 @@ #ifndef GUARD_CONSTANTS_CRIES_H #define GUARD_CONSTANTS_CRIES_H -enum { +enum PokemonCry +{ CRY_NONE, #if P_FAMILY_BULBASAUR CRY_BULBASAUR, diff --git a/include/constants/pokedex.h b/include/constants/pokedex.h index 241198e178..fd5ad2eb7b 100644 --- a/include/constants/pokedex.h +++ b/include/constants/pokedex.h @@ -3,7 +3,8 @@ // National Pokédex order // These constants are NOT disabled by P_GEN_X_POKEMON to keep pokedex_orders.h clean. -enum { +enum NationalDexOrder +{ NATIONAL_DEX_NONE, // Kanto NATIONAL_DEX_BULBASAUR, @@ -1063,7 +1064,8 @@ enum { #define POKEMON_SLOTS_NUMBER (NATIONAL_DEX_COUNT + 1) // Hoenn Pokédex order -enum { +enum HoennDexOrder +{ HOENN_DEX_NONE, HOENN_DEX_TREECKO, HOENN_DEX_GROVYLE, diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 659193861c..af01007cd2 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -218,29 +218,38 @@ #define EV_ITEM_RAISE_LIMIT ((I_VITAMIN_EV_CAP >= GEN_8) ? MAX_PER_STAT_EVS : 100) // Move category defines. -#define DAMAGE_CATEGORY_PHYSICAL 0 -#define DAMAGE_CATEGORY_SPECIAL 1 -#define DAMAGE_CATEGORY_STATUS 2 +enum DamageCategory +{ + DAMAGE_CATEGORY_PHYSICAL, + DAMAGE_CATEGORY_SPECIAL, + DAMAGE_CATEGORY_STATUS +}; // Growth rates -#define GROWTH_MEDIUM_FAST 0 -#define GROWTH_ERRATIC 1 -#define GROWTH_FLUCTUATING 2 -#define GROWTH_MEDIUM_SLOW 3 -#define GROWTH_FAST 4 -#define GROWTH_SLOW 5 +enum GrowthRate +{ + GROWTH_MEDIUM_FAST, + GROWTH_ERRATIC, + GROWTH_FLUCTUATING, + GROWTH_MEDIUM_SLOW, + GROWTH_FAST, + GROWTH_SLOW, +}; // Body colors for Pokédex search -#define BODY_COLOR_RED 0 -#define BODY_COLOR_BLUE 1 -#define BODY_COLOR_YELLOW 2 -#define BODY_COLOR_GREEN 3 -#define BODY_COLOR_BLACK 4 -#define BODY_COLOR_BROWN 5 -#define BODY_COLOR_PURPLE 6 -#define BODY_COLOR_GRAY 7 -#define BODY_COLOR_WHITE 8 -#define BODY_COLOR_PINK 9 +enum BodyColor +{ + BODY_COLOR_RED, + BODY_COLOR_BLUE, + BODY_COLOR_YELLOW, + BODY_COLOR_GREEN, + BODY_COLOR_BLACK, + BODY_COLOR_BROWN, + BODY_COLOR_PURPLE, + BODY_COLOR_GRAY, + BODY_COLOR_WHITE, + BODY_COLOR_PINK, +}; #define F_SUMMARY_SCREEN_FLIP_SPRITE 0x80 diff --git a/include/move.h b/include/move.h index b8c99257b2..deb9b7d85d 100644 --- a/include/move.h +++ b/include/move.h @@ -69,7 +69,7 @@ struct MoveInfo const u8 *description; u16 effect; u16 type:5; // Up to 32 - u16 category:2; + enum DamageCategory category:2; u16 power:9; // up to 511 // end of word u16 accuracy:7; @@ -200,7 +200,7 @@ static inline u32 GetMoveType(u32 moveId) return gMovesInfo[SanitizeMoveId(moveId)].type; } -static inline u32 GetMoveCategory(u32 moveId) +static inline enum DamageCategory GetMoveCategory(u32 moveId) { return gMovesInfo[SanitizeMoveId(moveId)].category; } diff --git a/include/pokedex.h b/include/pokedex.h index aa88834e67..0dfc802312 100644 --- a/include/pokedex.h +++ b/include/pokedex.h @@ -8,9 +8,9 @@ void ResetPokedex(void); u16 GetNationalPokedexCount(u8 caseID); u16 GetHoennPokedexCount(u8 caseID); u8 DisplayCaughtMonDexPage(u16 species, bool32 isShiny, u32 personality); -s8 GetSetPokedexFlag(u16 nationalDexNo, u8 caseID); +s8 GetSetPokedexFlag(enum NationalDexOrder nationalDexNo, u8 caseID); void DrawFootprint(u8 windowId, u16 species); -u16 CreateMonSpriteFromNationalDexNumber(u16 nationalNum, s16 x, s16 y, u16 paletteSlot); +u16 CreateMonSpriteFromNationalDexNumber(enum NationalDexOrder nationalNum, s16 x, s16 y, u16 paletteSlot); bool16 HasAllHoennMons(void); void ResetPokedexScrollPositions(void); bool16 HasAllMons(void); diff --git a/include/pokemon.h b/include/pokemon.h index 966d5f6a35..3b4cc0715b 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -4,6 +4,7 @@ #include "contest_effect.h" #include "sprite.h" #include "constants/battle.h" +#include "constants/cries.h" #include "constants/form_change_types.h" #include "constants/items.h" #include "constants/map_groups.h" @@ -431,8 +432,8 @@ struct SpeciesInfo /*0xC4*/ // Pokédex data u8 categoryName[13]; u8 speciesName[POKEMON_NAME_LENGTH + 1]; - u16 cryId; - u16 natDexNum; + enum PokemonCry cryId:16; + enum NationalDexOrder natDexNum:16; u16 height; //in decimeters u16 weight; //in hectograms u16 pokemonScale; @@ -440,7 +441,7 @@ struct SpeciesInfo /*0xC4*/ u16 trainerScale; u16 trainerOffset; const u8 *description; - u8 bodyColor:7; + enum BodyColor bodyColor:7; // Graphical Data u8 noFlip:1; u8 frontAnimDelay; @@ -789,11 +790,11 @@ u32 GetGMaxTargetSpecies(u32 species); bool32 DoesMonMeetAdditionalConditions(struct Pokemon *mon, const struct EvolutionParam *params, struct Pokemon *tradePartner, u32 partyId, bool32 *canStopEvo, enum EvoState evoState); u32 GetEvolutionTargetSpecies(struct Pokemon *mon, enum EvolutionMode mode, u16 evolutionItem, struct Pokemon *tradePartner, bool32 *canStopEvo, enum EvoState evoState); bool8 IsMonPastEvolutionLevel(struct Pokemon *mon); -u16 NationalPokedexNumToSpecies(u16 nationalNum); -u16 NationalToHoennOrder(u16 nationalNum); -u16 SpeciesToNationalPokedexNum(u16 species); -u16 SpeciesToHoennPokedexNum(u16 species); -u16 HoennToNationalOrder(u16 hoennNum); +u16 NationalPokedexNumToSpecies(enum NationalDexOrder nationalNum); +enum HoennDexOrder NationalToHoennOrder(enum NationalDexOrder nationalNum); +enum NationalDexOrder SpeciesToNationalPokedexNum(u16 species); +enum HoennDexOrder SpeciesToHoennPokedexNum(u16 species); +enum NationalDexOrder HoennToNationalOrder(enum HoennDexOrder hoennNum); void DrawSpindaSpots(u32 personality, u8 *dest, bool32 isSecondFrame); void EvolutionRenameMon(struct Pokemon *mon, u16 oldSpecies, u16 newSpecies); u8 GetPlayerFlankId(void); @@ -843,7 +844,7 @@ void BattleAnimateBackSprite(struct Sprite *sprite, u16 species); u8 GetOpposingLinkMultiBattlerId(bool8 rightSide, u8 multiplayerId); u16 FacilityClassToPicIndex(u16 facilityClass); u16 PlayerGenderToFrontTrainerPicId(u8 playerGender); -void HandleSetPokedexFlag(u16 nationalNum, u8 caseId, u32 personality); +void HandleSetPokedexFlag(enum NationalDexOrder nationalNum, u8 caseId, u32 personality); bool8 HasTwoFramesAnimation(u16 species); struct MonSpritesGfxManager *CreateMonSpritesGfxManager(u8 managerId, u8 mode); void DestroyMonSpritesGfxManager(u8 managerId); @@ -865,7 +866,7 @@ void UpdateMonPersonality(struct BoxPokemon *boxMon, u32 personality); u8 CalculatePartyCount(struct Pokemon *party); u16 SanitizeSpeciesId(u16 species); bool32 IsSpeciesEnabled(u16 species); -u16 GetCryIdBySpecies(u16 species); +enum PokemonCry GetCryIdBySpecies(u16 species); u16 GetSpeciesPreEvolution(u16 species); void HealPokemon(struct Pokemon *mon); void HealBoxPokemon(struct BoxPokemon *boxMon); diff --git a/src/battle_ai_util.c b/src/battle_ai_util.c index 01dab74882..cc692fbcb7 100644 --- a/src/battle_ai_util.c +++ b/src/battle_ai_util.c @@ -421,7 +421,7 @@ bool32 IsAffectedByPowder(u32 battler, u32 ability, enum ItemHoldEffect holdEffe // This function checks if all physical/special moves are either unusable or unreasonable to use. // Consider a pokemon boosting their attack against a ghost pokemon having only normal-type physical attacks. -bool32 MovesWithCategoryUnusable(u32 attacker, u32 target, u32 category) +bool32 MovesWithCategoryUnusable(u32 attacker, u32 target, enum DamageCategory category) { u32 usable = 0; u16 *moves = GetMovesArray(attacker); @@ -2124,7 +2124,7 @@ u16 *GetMovesArray(u32 battler) return gBattleHistory->usedMoves[battler]; } -bool32 HasOnlyMovesWithCategory(u32 battlerId, u32 category, bool32 onlyOffensive) +bool32 HasOnlyMovesWithCategory(u32 battlerId, enum DamageCategory category, bool32 onlyOffensive) { u32 i; u16 *moves = GetMovesArray(battlerId); @@ -2140,7 +2140,7 @@ bool32 HasOnlyMovesWithCategory(u32 battlerId, u32 category, bool32 onlyOffensiv return TRUE; } -bool32 HasMoveWithCategory(u32 battler, u32 category) +bool32 HasMoveWithCategory(u32 battler, enum DamageCategory category) { u32 i; u16 *moves = GetMovesArray(battler); @@ -3952,7 +3952,7 @@ bool32 IsPartyFullyHealedExceptBattler(u32 battlerId) return TRUE; } -bool32 PartyHasMoveCategory(u32 battlerId, u32 category) +bool32 PartyHasMoveCategory(u32 battlerId, enum DamageCategory category) { struct Pokemon *party = GetBattlerParty(battlerId); u32 i, j; @@ -3979,7 +3979,7 @@ bool32 PartyHasMoveCategory(u32 battlerId, u32 category) return FALSE; } -bool32 SideHasMoveCategory(u32 battlerId, u32 category) +bool32 SideHasMoveCategory(u32 battlerId, enum DamageCategory category) { if (IsDoubleBattle()) { diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 65622b9a5a..1d7f2579e8 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -5055,7 +5055,7 @@ static void Cmd_getexp(void) if (B_EXP_CAP_TYPE == EXP_CAP_HARD && gBattleStruct->battlerExpReward != 0) { - u32 growthRate = gSpeciesInfo[GetMonData(&gPlayerParty[*expMonId], MON_DATA_SPECIES)].growthRate; + enum GrowthRate growthRate = gSpeciesInfo[GetMonData(&gPlayerParty[*expMonId], MON_DATA_SPECIES)].growthRate; u32 currentExp = GetMonData(&gPlayerParty[*expMonId], MON_DATA_EXP); u32 levelCap = GetCurrentLevelCap(); diff --git a/src/battle_util.c b/src/battle_util.c index cf82841ed8..6937acc088 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -6007,7 +6007,7 @@ static enum ItemEffect TrySetEnigmaBerry(u32 battler) return ITEM_NO_EFFECT; } -static enum ItemEffect DamagedStatBoostBerryEffect(u32 battler, u8 statId, u8 category) +static enum ItemEffect DamagedStatBoostBerryEffect(u32 battler, u8 statId, enum DamageCategory category) { if (IsBattlerAlive(battler) && CompareStat(battler, statId, MAX_STAT_STAGE, CMP_LESS_THAN) @@ -10347,7 +10347,7 @@ bool32 ShouldGetStatBadgeBoost(u16 badgeFlag, u32 battler) return FALSE; } -static u32 SwapMoveDamageCategory(u32 move) +static enum DamageCategory SwapMoveDamageCategory(u32 move) { if (GetMoveCategory(move) == DAMAGE_CATEGORY_PHYSICAL) return DAMAGE_CATEGORY_SPECIAL; @@ -10359,7 +10359,7 @@ static u32 SwapMoveDamageCategory(u32 move) can be removed but a lot of function arguments (battlerAtk and battlerDef) have to be added for this, about 50+. This is potentially a good change because it is less likely to cause bugs in the future. */ -u32 GetBattleMoveCategory(u32 move) +enum DamageCategory GetBattleMoveCategory(u32 move) { if (gMain.inBattle) { @@ -10449,7 +10449,7 @@ static bool32 IsUnnerveAbilityOnOpposingSide(u32 battler) } // Photon Geyser, Light That Burns the Sky, Tera Blast -u8 GetCategoryBasedOnStats(u32 battler) +enum DamageCategory GetCategoryBasedOnStats(u32 battler) { u32 attack = gBattleMons[battler].attack; u32 spAttack = gBattleMons[battler].spAttack; diff --git a/src/contest_util.c b/src/contest_util.c index 2fd5a7575a..3bd5e1ec5f 100644 --- a/src/contest_util.c +++ b/src/contest_util.c @@ -964,7 +964,8 @@ static void Task_ShowWinnerMonBanner(u8 taskId) static void Task_SetSeenWinnerMon(u8 taskId) { - int i, nationalDexNum; + int i; + enum NationalDexOrder nationalDexNum; if (JOY_NEW(A_BUTTON)) { diff --git a/src/credits.c b/src/credits.c index 7977db6e5d..bfc2cda12a 100644 --- a/src/credits.c +++ b/src/credits.c @@ -1542,7 +1542,7 @@ static void SpriteCB_CreditsMonBg(struct Sprite *sprite) static void DeterminePokemonToShow(void) { - u16 starter = SpeciesToNationalPokedexNum(GetStarterPokemon(VarGet(VAR_STARTER_MON))); + enum NationalDexOrder starter = SpeciesToNationalPokedexNum(GetStarterPokemon(VarGet(VAR_STARTER_MON))); u16 page; u16 dexNum; u16 j; diff --git a/src/debug.c b/src/debug.c index bdef2b6d98..f1a8de68c1 100644 --- a/src/debug.c +++ b/src/debug.c @@ -3677,7 +3677,7 @@ static void DebugAction_Give_Pokemon_Move(u8 taskId) static void DebugAction_Give_Pokemon_ComplexCreateMon(u8 taskId) //https://github.com/ghoulslash/pokeemerald/tree/custom-givemon { - u16 nationalDexNum; + enum NationalDexOrder nationalDexNum; int sentToPc; struct Pokemon mon; u8 i; diff --git a/src/dexnav.c b/src/dexnav.c index a839cc1208..38a5323994 100644 --- a/src/dexnav.c +++ b/src/dexnav.c @@ -1909,7 +1909,7 @@ static void DexNavFadeAndExit(void) static bool8 SpeciesInArray(u16 species, u8 section) { u32 i; - u16 dexNum = SpeciesToNationalPokedexNum(species); + enum NationalDexOrder dexNum = SpeciesToNationalPokedexNum(species); switch (section) { @@ -2122,7 +2122,7 @@ static void SetTypeIconPosAndPal(u8 typeId, u8 x, u8 y, u8 spriteArrayId) static void PrintCurrentSpeciesInfo(void) { u16 species = DexNavGetSpecies(); - u16 dexNum = SpeciesToNationalPokedexNum(species); + enum NationalDexOrder dexNum = SpeciesToNationalPokedexNum(species); u8 type1, type2; if (!GetSetPokedexFlag(dexNum, FLAG_GET_SEEN)) diff --git a/src/easy_chat.c b/src/easy_chat.c index 7bb3107120..7c0871cb78 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -5545,7 +5545,7 @@ static u16 GetRandomUnlockedEasyChatPokemon(void) numWords = gEasyChatGroups[EC_GROUP_POKEMON].numWords; for (i = 0; i < numWords; i++) { - u16 dexNum = SpeciesToNationalPokedexNum(*species); + enum NationalDexOrder dexNum = SpeciesToNationalPokedexNum(*species); if (GetSetPokedexFlag(dexNum, FLAG_GET_SEEN)) { if (index) diff --git a/src/egg_hatch.c b/src/egg_hatch.c index f65ee674d8..d965c0c742 100644 --- a/src/egg_hatch.c +++ b/src/egg_hatch.c @@ -362,7 +362,7 @@ static void CreateHatchedMon(struct Pokemon *egg, struct Pokemon *temp) static void AddHatchedMonToParty(u8 id) { u8 isEgg = 0x46; // ? - u16 species; + enum NationalDexOrder species; u8 name[POKEMON_NAME_LENGTH + 1]; u16 metLevel; u8 metLocation; diff --git a/src/mystery_event_script.c b/src/mystery_event_script.c index 8ef53351f8..c50ef5f963 100644 --- a/src/mystery_event_script.c +++ b/src/mystery_event_script.c @@ -340,7 +340,7 @@ bool8 MEScrCmd_givepokemon(struct ScriptContext *ctx) if (species != SPECIES_EGG) { - u16 pokedexNum = SpeciesToNationalPokedexNum(species); + enum NationalDexOrder pokedexNum = SpeciesToNationalPokedexNum(species); GetSetPokedexFlag(pokedexNum, FLAG_SET_SEEN); GetSetPokedexFlag(pokedexNum, FLAG_SET_CAUGHT); } diff --git a/src/pokedex.c b/src/pokedex.c index bc305a4b4a..91fe39367b 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -4044,7 +4044,7 @@ static void Task_DisplayCaughtMonDexPage(u8 taskId) { u8 spriteId; u16 species = gTasks[taskId].tSpecies; - u16 dexNum = SpeciesToNationalPokedexNum(species); + enum NationalDexOrder dexNum = SpeciesToNationalPokedexNum(species); switch (gTasks[taskId].tState) { @@ -4513,7 +4513,7 @@ static u8* ConvertMeasurementToMetricString(u32 num, u32* index) return string; } -s8 GetSetPokedexFlag(u16 nationalDexNo, u8 caseID) +s8 GetSetPokedexFlag(enum NationalDexOrder nationalDexNo, u8 caseID) { u32 index, bit, mask; s8 retVal = 0; @@ -4890,7 +4890,7 @@ static u32 GetPokedexMonPersonality(u16 species) } } -u16 CreateMonSpriteFromNationalDexNumber(u16 nationalNum, s16 x, s16 y, u16 paletteSlot) +u16 CreateMonSpriteFromNationalDexNumber(enum NationalDexOrder nationalNum, s16 x, s16 y, u16 paletteSlot) { nationalNum = NationalPokedexNumToSpecies(nationalNum); return CreateMonPicSprite(nationalNum, FALSE, GetPokedexMonPersonality(nationalNum), TRUE, x, y, paletteSlot, TAG_NONE); @@ -4925,7 +4925,7 @@ static u16 CreateSizeScreenTrainerPic(u16 species, s16 x, s16 y, s8 paletteSlot) return CreateTrainerPicSprite(species, TRUE, x, y, paletteSlot, TAG_NONE); } -static int DoPokedexSearch(u8 dexMode, u8 order, u8 abcGroup, u8 bodyColor, u8 type1, u8 type2) +static int DoPokedexSearch(u8 dexMode, u8 order, u8 abcGroup, enum BodyColor bodyColor, u8 type1, u8 type2) { u16 species; u16 i; @@ -5336,7 +5336,7 @@ static void Task_StartPokedexSearch(u8 taskId) u8 dexMode = GetSearchModeSelection(taskId, SEARCH_MODE); u8 order = GetSearchModeSelection(taskId, SEARCH_ORDER); u8 abcGroup = GetSearchModeSelection(taskId, SEARCH_NAME); - u8 bodyColor = GetSearchModeSelection(taskId, SEARCH_COLOR); + enum BodyColor bodyColor = GetSearchModeSelection(taskId, SEARCH_COLOR); u8 type1 = GetSearchModeSelection(taskId, SEARCH_TYPE_LEFT); u8 type2 = GetSearchModeSelection(taskId, SEARCH_TYPE_RIGHT); diff --git a/src/pokedex_plus_hgss.c b/src/pokedex_plus_hgss.c index 15cc80a438..938fbf152b 100644 --- a/src/pokedex_plus_hgss.c +++ b/src/pokedex_plus_hgss.c @@ -354,7 +354,7 @@ struct PokemonStats u8 evYield_Defense; u8 evYield_SpDefense; u8 catchRate; - u8 growthRate; + enum GrowthRate growthRate:8; u8 eggGroup1; u8 eggGroup2; u8 eggCycles; @@ -590,7 +590,7 @@ static void Task_SwitchScreensFromFormsScreen(u8 taskId); static void Task_ExitFormsScreen(u8 taskId); //Physical/Special/Status category icon -static u8 ShowCategoryIcon(u32 category); +static u8 ShowCategoryIcon(enum DamageCategory category); static void DestroyCategoryIcon(void); static u16 NationalPokedexNumToSpeciesHGSS(u16 nationalNum); @@ -4090,7 +4090,7 @@ void Task_DisplayCaughtMonDexPageHGSS(u8 taskId) { u8 spriteId; u16 species; - u16 dexNum; + enum NationalDexOrder dexNum; if (!POKEDEX_PLUS_HGSS) return; // prevents the compiler from emitting static .rodata // if the feature is disabled @@ -4701,7 +4701,7 @@ static void LoadTilesetTilemapHGSS(u8 page) } //Physical/Special/Status category -static u8 ShowCategoryIcon(u32 category) +static u8 ShowCategoryIcon(enum DamageCategory category) { if (sPokedexView->categoryIconSpriteId == 0xFF) sPokedexView->categoryIconSpriteId = CreateSprite(&gSpriteTemplate_CategoryIcons, 139, 90, 0); @@ -5622,7 +5622,7 @@ static void PrintStatsScreen_Left(u8 taskId) if (gTasks[taskId].data[5] == 0) { u32 catchRate = sPokedexView->sPokemonStats.catchRate; - u32 growthRate = sPokedexView->sPokemonStats.growthRate; + enum GrowthRate growthRate = sPokedexView->sPokemonStats.growthRate; //Catch rate PrintStatsScreenTextSmall(WIN_STATS_LEFT, sText_Stats_CatchRate, base_x, base_y + base_y_offset*base_i); @@ -6178,8 +6178,8 @@ static void Task_HandleEvolutionScreenInput(u8 taskId) if (JOY_NEW(A_BUTTON)) { - u16 targetSpecies = sPokedexView->sEvoScreenData.targetSpecies[sPokedexView->sEvoScreenData.menuPos]; - u16 dexNum = SpeciesToNationalPokedexNum(targetSpecies); + u16 targetSpecies = sPokedexView->sEvoScreenData.targetSpecies[sPokedexView->sEvoScreenData.menuPos]; + enum NationalDexOrder dexNum = SpeciesToNationalPokedexNum(targetSpecies); if (sPokedexView->isSearchResults && sPokedexView->originalSearchSelectionNum == 0) sPokedexView->originalSearchSelectionNum = sPokedexListItem->dexNum; @@ -7747,7 +7747,7 @@ static void Task_ClosePokedexFromSearchResultsStartMenu(u8 taskId) //* Search code * //* * //************************************ -static int DoPokedexSearch(u8 dexMode, u8 order, u8 abcGroup, u8 bodyColor, u8 type1, u8 type2) +static int DoPokedexSearch(u8 dexMode, u8 order, u8 abcGroup, enum BodyColor bodyColor, u8 type1, u8 type2) { u16 species; u16 i; @@ -8163,7 +8163,7 @@ static void Task_StartPokedexSearch(u8 taskId) u8 dexMode = GetSearchModeSelection(taskId, SEARCH_MODE); u8 order = GetSearchModeSelection(taskId, SEARCH_ORDER); u8 abcGroup = GetSearchModeSelection(taskId, SEARCH_NAME); - u8 bodyColor = GetSearchModeSelection(taskId, SEARCH_COLOR); + enum BodyColor bodyColor = GetSearchModeSelection(taskId, SEARCH_COLOR); u8 type1 = GetSearchModeSelection(taskId, SEARCH_TYPE_LEFT); u8 type2 = GetSearchModeSelection(taskId, SEARCH_TYPE_RIGHT); diff --git a/src/pokemon.c b/src/pokemon.c index 35f727e59e..0fc4df1212 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -119,7 +119,7 @@ static const struct CombinedMove sCombinedMoves[2] = #define HOENN_TO_NATIONAL(name) [HOENN_DEX_##name - 1] = NATIONAL_DEX_##name // Assigns all Hoenn Dex Indexes to a National Dex Index -static const u16 sHoennToNationalOrder[HOENN_DEX_COUNT - 1] = +static const enum NationalDexOrder sHoennToNationalOrder[HOENN_DEX_COUNT - 1] = { HOENN_TO_NATIONAL(TREECKO), HOENN_TO_NATIONAL(GROVYLE), @@ -5041,7 +5041,7 @@ bool8 IsMonPastEvolutionLevel(struct Pokemon *mon) return FALSE; } -u16 NationalPokedexNumToSpecies(u16 nationalNum) +u16 NationalPokedexNumToSpecies(enum NationalDexOrder nationalNum) { u16 species; @@ -5059,7 +5059,7 @@ u16 NationalPokedexNumToSpecies(u16 nationalNum) return GET_BASE_SPECIES_ID(species); } -u16 NationalToHoennOrder(u16 nationalNum) +enum HoennDexOrder NationalToHoennOrder(enum NationalDexOrder nationalNum) { u16 hoennNum; @@ -5077,7 +5077,7 @@ u16 NationalToHoennOrder(u16 nationalNum) return hoennNum + 1; } -u16 SpeciesToNationalPokedexNum(u16 species) +enum NationalDexOrder SpeciesToNationalPokedexNum(u16 species) { species = SanitizeSpeciesId(species); if (!species) @@ -5086,14 +5086,14 @@ u16 SpeciesToNationalPokedexNum(u16 species) return gSpeciesInfo[species].natDexNum; } -u16 SpeciesToHoennPokedexNum(u16 species) +enum HoennDexOrder SpeciesToHoennPokedexNum(u16 species) { if (!species) return 0; return NationalToHoennOrder(gSpeciesInfo[species].natDexNum); } -u16 HoennToNationalOrder(u16 hoennNum) +enum NationalDexOrder HoennToNationalOrder(enum HoennDexOrder hoennNum) { if (!hoennNum || hoennNum >= HOENN_DEX_COUNT) return 0; @@ -6404,7 +6404,7 @@ u16 PlayerGenderToFrontTrainerPicId(u8 playerGender) return FacilityClassToPicIndex(FACILITY_CLASS_BRENDAN); } -void HandleSetPokedexFlag(u16 nationalNum, u8 caseId, u32 personality) +void HandleSetPokedexFlag(enum NationalDexOrder nationalNum, u8 caseId, u32 personality) { u8 getFlagCaseId = (caseId == FLAG_SET_SEEN) ? FLAG_GET_SEEN : FLAG_GET_CAUGHT; if (!GetSetPokedexFlag(nationalNum, getFlagCaseId)) // don't set if it's already set @@ -7059,7 +7059,7 @@ void HealBoxPokemon(struct BoxPokemon *boxMon) BoxMonRestorePP(boxMon); } -u16 GetCryIdBySpecies(u16 species) +enum PokemonCry GetCryIdBySpecies(u16 species) { species = SanitizeSpeciesId(species); if (P_CRIES_ENABLED == FALSE || gSpeciesInfo[species].cryId >= CRY_COUNT || gTestRunnerHeadless) diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index e4abb9f163..3bf7c0aac4 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -1156,7 +1156,7 @@ static const struct SpriteTemplate sSpriteTemplate_StatusCondition = static const u16 sMarkings_Pal[] = INCBIN_U16("graphics/summary_screen/markings.gbapal"); // code -static u8 ShowCategoryIcon(u32 category) +static u8 ShowCategoryIcon(enum DamageCategory category) { if (sMonSummaryScreen->categoryIconSpriteId == 0xFF) sMonSummaryScreen->categoryIconSpriteId = CreateSprite(&gSpriteTemplate_CategoryIcons, 48, 128, 0); diff --git a/src/scrcmd.c b/src/scrcmd.c index 3f71fb6798..569e6a90bf 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -3099,7 +3099,7 @@ bool8 ScrCmd_checkobjectat(struct ScriptContext *ctx) bool8 Scrcmd_getsetpokedexflag(struct ScriptContext *ctx) { - u32 speciesId = SpeciesToNationalPokedexNum(VarGet(ScriptReadHalfword(ctx))); + enum NationalDexOrder speciesId = SpeciesToNationalPokedexNum(VarGet(ScriptReadHalfword(ctx))); u32 desiredFlag = VarGet(ScriptReadHalfword(ctx)); if (desiredFlag == FLAG_SET_CAUGHT || desiredFlag == FLAG_SET_SEEN) diff --git a/src/script_pokemon_util.c b/src/script_pokemon_util.c index 7288870441..359ab75e41 100644 --- a/src/script_pokemon_util.c +++ b/src/script_pokemon_util.c @@ -334,7 +334,7 @@ void SetTeraType(struct ScriptContext *ctx) */ static u32 ScriptGiveMonParameterized(u8 side, u8 slot, u16 species, u8 level, u16 item, enum PokeBall ball, u8 nature, u8 abilityNum, u8 gender, u8 *evs, u8 *ivs, u16 *moves, bool8 isShiny, bool8 gmaxFactor, u8 teraType, u8 dmaxLevel) { - u16 nationalDexNum; + enum NationalDexOrder nationalDexNum; int sentToPc; struct Pokemon mon; u32 i; diff --git a/src/sound.c b/src/sound.c index 5b4ae29f71..f1f10f3b03 100644 --- a/src/sound.c +++ b/src/sound.c @@ -467,11 +467,11 @@ void PlayCryInternal(u16 species, s8 pan, s8 volume, u8 priority, u8 mode) SetPokemonCryChorus(chorus); SetPokemonCryPriority(priority); - species = GetCryIdBySpecies(species); - if (species != CRY_NONE) + enum PokemonCry cryId = GetCryIdBySpecies(species); + if (cryId != CRY_NONE) { - species--; - gMPlay_PokemonCry = SetPokemonCryTone(reverse ? &gCryTable_Reverse[species] : &gCryTable[species]); + cryId--; + gMPlay_PokemonCry = SetPokemonCryTone(reverse ? &gCryTable_Reverse[cryId] : &gCryTable[cryId]); } } diff --git a/src/trade.c b/src/trade.c index dbb8622b80..5fd04e1f82 100644 --- a/src/trade.c +++ b/src/trade.c @@ -3057,9 +3057,9 @@ static void UpdatePokedexForReceivedMon(u8 partyIdx) { u16 species = GetMonData(mon, MON_DATA_SPECIES, NULL); u32 personality = GetMonData(mon, MON_DATA_PERSONALITY, NULL); - species = SpeciesToNationalPokedexNum(species); - GetSetPokedexFlag(species, FLAG_SET_SEEN); - HandleSetPokedexFlag(species, FLAG_SET_CAUGHT, personality); + enum NationalDexOrder dexNum = SpeciesToNationalPokedexNum(species); + GetSetPokedexFlag(dexNum, FLAG_SET_SEEN); + HandleSetPokedexFlag(dexNum, FLAG_SET_CAUGHT, personality); } } diff --git a/src/trainer_pools.c b/src/trainer_pools.c index a2db4d81f5..ec38c7a01f 100644 --- a/src/trainer_pools.c +++ b/src/trainer_pools.c @@ -169,7 +169,7 @@ static u32 PickMonFromPool(const struct Trainer *trainer, u8 *poolIndexArray, u3 u32 chosenTags = trainer->party[monIndex].tags; u16 chosenSpecies = trainer->party[monIndex].species; u16 chosenItem = trainer->party[monIndex].heldItem; - u16 chosenNatDex = gSpeciesInfo[chosenSpecies].natDexNum; + enum NationalDexOrder chosenNatDex = gSpeciesInfo[chosenSpecies].natDexNum; // If tag was required, change pool rule to account for the required tag already being picked u32 tagsToEliminate = 0; for (u32 currTag = 0; currTag < POOL_NUM_TAGS; currTag++) @@ -197,7 +197,7 @@ static u32 PickMonFromPool(const struct Trainer *trainer, u8 *poolIndexArray, u3 u32 currentTags = trainer->party[poolIndexArray[currIndex]].tags; u16 currentSpecies = trainer->party[poolIndexArray[currIndex]].species; u16 currentItem = trainer->party[poolIndexArray[currIndex]].heldItem; - u16 currentNatDex = gSpeciesInfo[currentSpecies].natDexNum; + enum NationalDexOrder currentNatDex = gSpeciesInfo[currentSpecies].natDexNum; if (currentTags & tagsToEliminate) { poolIndexArray[currIndex] = POOL_SLOT_DISABLED;