summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/battle_anim_mons.c7
-rw-r--r--src/battle_main.c2
-rw-r--r--src/decompress.c6
-rw-r--r--src/pokemon.c4
-rw-r--r--src/pokemon_icon.c2
5 files changed, 7 insertions, 14 deletions
diff --git a/src/battle_anim_mons.c b/src/battle_anim_mons.c
index d626e1604..0c3d4ea47 100644
--- a/src/battle_anim_mons.c
+++ b/src/battle_anim_mons.c
@@ -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;
diff --git a/src/battle_main.c b/src/battle_main.c
index 7e8966597..940fab8ff 100644
--- a/src/battle_main.c
+++ b/src/battle_main.c
@@ -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)
diff --git a/src/decompress.c b/src/decompress.c
index 007753303..335699449 100644
--- a/src/decompress.c
+++ b/src/decompress.c
@@ -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)
diff --git a/src/pokemon.c b/src/pokemon.c
index 5829bbd0a..94bbd0dc4 100644
--- a/src/pokemon.c
+++ b/src/pokemon.c
@@ -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)
diff --git a/src/pokemon_icon.c b/src/pokemon_icon.c
index b85a29151..065b8e22e 100644
--- a/src/pokemon_icon.c
+++ b/src/pokemon_icon.c
@@ -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)