Use GET_UNOWN_LETTER macro

This commit is contained in:
GriffinR 2021-01-19 04:03:16 -05:00
parent f19d1b2590
commit bc20fda604
6 changed files with 16 additions and 14 deletions

View File

@ -238,6 +238,15 @@ struct Evolution
u16 targetSpecies;
};
#define NUM_UNOWN_FORMS 28
#define GET_UNOWN_LETTER(personality) (( \
((personality & 0x03000000) >> 18) \
| ((personality & 0x00030000) >> 12) \
| ((personality & 0x00000300) >> 6) \
| ((personality & 0x00000003) >> 0) \
) % NUM_UNOWN_FORMS)
extern u8 gPlayerPartyCount;
extern struct Pokemon gPlayerParty[PARTY_SIZE];
extern u8 gEnemyPartyCount;

View File

@ -16,13 +16,6 @@
#include "util.h"
#include "constants/battle_anim.h"
#define GET_UNOWN_LETTER(personality) (( \
(((personality & 0x03000000) >> 24) << 6) \
| (((personality & 0x00030000) >> 16) << 4) \
| (((personality & 0x00000300) >> 8) << 2) \
| (((personality & 0x00000003) >> 0) << 0) \
) % 28)
#define IS_DOUBLE_BATTLE() ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE))
extern const struct OamData gOamData_AffineNormal_ObjNormal_64x64;

View File

@ -2722,7 +2722,7 @@ void SpriteCB_FaintOpponentMon(struct Sprite *sprite)
if (species == SPECIES_UNOWN)
{
u32 personalityValue = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_PERSONALITY);
u16 unownForm = ((((personalityValue & 0x3000000) >> 18) | ((personalityValue & 0x30000) >> 12) | ((personalityValue & 0x300) >> 6) | (personalityValue & 3)) % 0x1C);
u16 unownForm = GET_UNOWN_LETTER(personalityValue);
u16 unownSpecies;
if (unownForm == 0)

View File

@ -86,7 +86,7 @@ void LoadSpecialPokePic(const struct CompressedSpriteSheet *src, void *dest, s32
{
if (species == SPECIES_UNOWN)
{
u16 i = (((personality & 0x3000000) >> 18) | ((personality & 0x30000) >> 12) | ((personality & 0x300) >> 6) | (personality & 3)) % 0x1C;
u16 i = GET_UNOWN_LETTER(personality);
// The other Unowns are separate from Unown A.
if (i == 0)
@ -308,7 +308,7 @@ void LoadSpecialPokePic_2(const struct CompressedSpriteSheet *src, void *dest, s
{
if (species == SPECIES_UNOWN)
{
u16 i = (((personality & 0x3000000) >> 18) | ((personality & 0x30000) >> 12) | ((personality & 0x300) >> 6) | (personality & 3)) % 0x1C;
u16 i = GET_UNOWN_LETTER(personality);
// The other Unowns are separate from Unown A.
if (i == 0)
@ -366,7 +366,7 @@ void LoadSpecialPokePic_DontHandleDeoxys(const struct CompressedSpriteSheet *src
{
if (species == SPECIES_UNOWN)
{
u16 i = (((personality & 0x3000000) >> 18) | ((personality & 0x30000) >> 12) | ((personality & 0x300) >> 6) | (personality & 3)) % 0x1C;
u16 i = GET_UNOWN_LETTER(personality);
// The other Unowns are separate from Unown A.
if (i == 0)

View File

@ -2304,14 +2304,14 @@ void CreateMonWithGenderNatureLetter(struct Pokemon *mon, u16 species, u8 level,
{
u32 personality;
if ((u8)(unownLetter - 1) < 28)
if ((u8)(unownLetter - 1) < NUM_UNOWN_FORMS)
{
u16 actualLetter;
do
{
personality = Random32();
actualLetter = ((((personality & 0x3000000) >> 18) | ((personality & 0x30000) >> 12) | ((personality & 0x300) >> 6) | (personality & 0x3)) % 28);
actualLetter = GET_UNOWN_LETTER(personality);
}
while (nature != GetNatureFromPersonality(personality)
|| gender != GetGenderFromSpeciesAndPersonality(species, personality)

View File

@ -1099,7 +1099,7 @@ u16 GetUnownLetterByPersonality(u32 personality)
if (!personality)
return 0;
else
return (((personality & 0x3000000) >> 18) | ((personality & 0x30000) >> 12) | ((personality & 0x300) >> 6) | (personality & 0x3)) % 0x1C;
return GET_UNOWN_LETTER(personality);
}
u16 sub_80D2E84(u16 species)